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
document.activeElement is always null after upgrading to jsdom 15/16 (jest 25) #2924
Comments
This does not follow the issue template; it uses invalid JavaScript syntax, and references undefined functions. Please edit the post to follow the issue template, producing a sample we can run in Node.js as a single file, and then add a comment. I would also strongly suggest a link to a jsbin or similar. At that time we can reopen and consider this issue. |
Interestingly, without enzyme-related stuff it works just fine: https://runkit.com/wojtekmaj/jsdom-15-2-16-document-activeelement-issue-ok However, I think it might be tightly coupled with #2586 which is still a regression since v15.2: https://runkit.com/wojtekmaj/jsdom-15-2-16-document-activeelement-issue |
Related: enzymejs/enzyme#2337 Looks like the break is caused by jsdom's increasing strictness about not setting |
Attach to what, exactly? |
To const wrapper = mount(App, { attachTo: document.body }); |
This did not work for me and produced the following error: Instead I created a div in the body like below: document.body.innerHTML = `<div id="wrap"></div>`;
const component = mount(
<Component />
// { attachTo: document.body } // This causes error
{ attachTo: wrap }
); |
Basic info:
We use jest tests with
expect(document.activeElement).toBe(myElement)
pattern to determine if an element got correctly focused after an interaction. After upgrading to jest 25 (jsdom 15) all such tests broke,document.activeElement
appears to be always null. It is also the case if we run it using jsDom 16.Jest team advised me to open an issue here.
Minimal reproduction case
How does similar code behave in browsers?
Focused element should be reflected in
document.activeElement
The text was updated successfully, but these errors were encountered: