@testing-library/dom version: 7.10.1jest@26.0.1 via @testing-library/react@10.2.1Relevant code or config
fireEvent.click(new Promise(jest.fn());
What you did:
This is a contrived example; what I actually did was pass the result of findByRole instead of getByRole.
What happened:
Unable to find the "window" object for the given node. Please file an issue with the code that's causing you to see this error: https://github.com/testing-library/dom-testing-library/issues/new
40 | await act(async () => {
> 41 | fireEvent.click(jest.fn());
| ^
42 | });
Problem description:
getWindowFromNode doesn't account for the node not being a Node.
Suggested solution:
Give an explicit error message if it's an instance of a Promise.
Yep, I had the same exact issue the other day where I tried to fireEvent.click(screen.findBy*(...)) instead of fireEvent.click(screen.getBy*(...)), completely by accident. It took me way too long to figure out the problem. :sweat_smile:
I'm good with this. Let's just check if it has a .then function and if it does we can give a helpful error message.
Though you may want to use typescript to avoid this 馃槈
This is an invitation to make a pull request 馃榿
I think we could add this to the eslint repo.
If I recall correctly we already have some helpers to find a Promise, so this should be not too hard to do.
That would definitely be cool
:tada: This issue has been resolved in version 7.15.0 :tada:
The release is available on:
npm package (@latest dist-tag)Your semantic-release bot :package::rocket:
Most helpful comment
This is an invitation to make a pull request 馃榿