-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch tests away from using enzyme.mount (components/higher-order/with-focus-outside/test/index.js) #7827
Switch tests away from using enzyme.mount (components/higher-order/with-focus-outside/test/index.js) #7827
Conversation
This switches all tests in `components/higher-order/with-focus-outside/test/index.js` from using enzyme.shallow and enzyme.mount to `React.TestUtils`. This is because `enzyme` does not fully support React 16.3+ (and movement to do so is really slow). This will fix issues with breakage due to the enzyme incompatibility as components receive React 16.3+ features (such as `forwardRef` usage in #7557).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had two minor comments, let me know what you think.
@@ -12,9 +12,12 @@ import { Component } from '@wordpress/element'; | |||
* Internal dependencies | |||
*/ | |||
import withFocusOutside from '../'; | |||
import ReactDOM from 'react-dom'; | |||
|
|||
jest.useFakeTimers(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside: we have fake timers enabled by default ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was already in this test, so likely can just be an additional improvement to the original test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you can remove at the same time, it would be awesome. It should work 😓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya looks like tests pass fine with it removed.
return <TestComponent />; | ||
}; | ||
|
||
const simulateEvent = ( event, position = 0 ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
position
is confusing in this context. I assumed this is position on the screen at first. Did you mean index
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change implemented
|
||
jest.useFakeTimers(); | ||
|
||
let wrapper, callback; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename callback
to onFocusOutside
to make it easier to read since it is now hidden inside beforeEach
method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change implemented
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
🚢
Description
This switches all tests in
components/higher-order/with-focus-outside/test/index.js
from using enzyme.shallow and enzyme.mount toReact.TestUtils
. This is becauseenzyme
does not fully support React 16.3+ (and movement to do so is really slow). This will fix issues with breakage due to the enzyme incompatibility as components receive React 16.3+ features (such asforwardRef
usage in #7557).Checklist: