-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
TypeError: Cannot read properties of null (reading 'createEvent') #1027
Comments
Hi @Zylphrex, thanks for taking the time to open this one. I'd recommend increasing the default timeout for this specific test as it might take time in lower CPU machines. |
I understand that the problem was that my test was timing out and that needs to be addressed. But the problem with testing-library here is that the error itself was not helpful in any way in tracking down the failure. For example, if I changed the test to something like
I simply removed the cleanup in the
|
Hmm, I get your point, but looking at this the other way around, it will be hard for us to write specific catch for all framework exceptions that might come along the way. The reason you're seeing the timeout without interacting with anything is that we're probably already rendering and just waiting for the side effect to finish so no error is thrown from React there. The reason you see a React error afterwards is since we're still in progress of running the test but jest has already cleared all of the resources that test was using. I'll re-open this one, maybe other maintainers will have different insights :) |
Thank you very much for the repro! Unfortunately, this looks like an issue with Jest: jestjs/jest#9056. Closing in favor of jestjs/jest#12670 until there's something actionable for us. |
I was receiving the same error and I was able to solve it by using |
My guess of why there was an error is that there's nothing left to wait for. Perhaps jest already shuts down the test, while react-testing-library is waiting to see more. Other people out there have experienced the same error: testing-library/react-testing-library#1027 (comment)
* Upgrade msw to latest * Bring back `server.close` * Fix one of the failing tests My guess of why there was an error is that there's nothing left to wait for. Perhaps jest already shuts down the test, while react-testing-library is waiting to see more. Other people out there have experienced the same error: testing-library/react-testing-library#1027 (comment) * Fix another test with similar strategy * Simplify the test so that it passes consistently Not sure why it seems to be timing out. And different results when only that single test is run vs running the whole test file. * Skip these tests for now * Fix AppConfig test * Fix the remaining checkout tests * Fix one of the cart tests * Tweak these cart tests * Try a different kind of query * Attempt at fixing this flaky test * Skip this test for now * Another attempt at fixing this flaky test * Try moving it out of the catch block * Update package-lock.json * Try moving it out of the catch block * Try moving it out of the catch block * Revert and exit early if we detect this test being flaky * Update comment * Skip this test only in CI * Mock response from additional endpoint * Trigger another round of tests * Update package lock * No longer run this test conditionally * Update package-lock.json
@testing-library/react
version: 12.1.4Relevant code or config:
What you did:
You can see the original failure in this github action. The original test is attached below from this pull request
I've stripped down the component and test to a minimal case, hence why the test may seem a little strange.
I had a test that did 2 asynchronous
findByText
calls with some the synchronous calls in between that was causing the test to timeout.What happened:
I was expecting a timeout error pointing at the specific test that had failed. Instead, my tests crashed with the following stacktrace.
Reproduction:
You can find a repro in https://github.com/Zylphrex/react-testing-library-error-repro
Problem description:
This error was causing an error without any indication which test was the culprit. This should be failing the test with a timeout, and the test that timed out should obvious.
Suggested solution:
The text was updated successfully, but these errors were encountered: