-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Update activeElement tests to use modern testing utils #3070
Conversation
🟢 No significant changes to |
c3e998e
to
187b9a0
Compare
187b9a0
to
51ec767
Compare
An imminent bump to SK and thus Jest exposes a case enzyme doesn't handle component mounting to jsdom in a way that is spec compliant, which then results in test that assert on document.activeElement failing. Fortunatly react-testing doesn't have this problem, so we can just use that instead
51ec767
to
b1ac67b
Compare
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.
Thanks @BPScott this looks good. The open issue is also super great context.
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.
Thank you for doing this!
Is there any internal documentation about how to test focus that we could point to in the body of this PR?
@@ -257,15 +245,15 @@ describe('<TrapFocus />', () => { | |||
|
|||
listenerMap.keydown({ | |||
keyCode: Key.Tab, | |||
target: lastNode(trapFocus), | |||
target: trapFocus.find('input')!.domNode, |
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.
This (and a few other instances) slightly diverges from the intent of the test but I feel good about this change.
Unfortunately there is none that I am aware of. But from working through this stuff it boils down to:
|
WHY are these changes introduced?
An imminent bump to SK and thus Jest exposes a case where enzyme doesn't handle component mounting to jsdom in a way that results in spec compliant focus management, which then results in tests that assert on document.activeElement failing.
Fortunately react-testing doesn't have this problem, so we can just usethat instead.
Gory details: enzymejs/enzyme#2337 (comment)
WHAT is this pull request doing?
Migrates a handful of test cases from enzyme to use react-testing
How to 🎩
Run tests and see they still pass