-
Notifications
You must be signed in to change notification settings - Fork 472
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
Unable to fire event on document #159
Comments
Not able to reproduce this error - see https://github.com/alexkrolick/repro-document-fire-event/blob/master/src/__tests__/index.test.js Please provide a minimal reproduction in Codepen or a repo if you can come up with one It seems possible that this error is due to something else, such as the node being queried being undefined/null import {fireEvent} from 'react-testing-library'
import React from 'react'
it('fireEvent on document.body should not error', () => {
fireEvent.keyDown(document.body, {
key: "Escape",
keyCode: 27,
which: 27
})
}) |
I am getting this same issue but when im trying to fire an event on document. also confirmed that |
Hey @abe4mvp, I think that it would be reasonable to change this: to this: // if the node does not have an owner document, then it probably _is_ the owner document
const window = (node.ownerDocument || node).defaultView If you would be willing to make a pull request for that (including a test) then we can merge it and you should be good to go :) |
🎉 This issue has been resolved in version 3.17.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
react-testing-library
version: 5.3.0react
version: 1.6.6.3node
version: 8.11.3yarn
version: 1.12.3Relevant code or config:
What happened:
TypeError: Cannot read property 'defaultView' of null
Suggested solution:
https://github.com/kentcdodds/dom-testing-library/blob/master/src/events.js#L324
Should handle document and window elements (possibly in more places)
The text was updated successfully, but these errors were encountered: