-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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 property 'close' of undefined #6068
Comments
Without a reproduction this isn't actionable |
How can I best provide the info that is needed? |
Setting up a repo which exhibits the error. Even if it doesn't happen every time, having some code where it happens sometimes might help us track it down. |
What appears to happen is that you have left some dangling asynchronous code after marking your test as finished. This usually happens on synchronous tests (i.e. tests not returning a There are a couple of things you can do to try to mitigate this:
|
I cannot provide a repo as it is not open source code. It is an Angular project using the I have tried to use the 23.0.0-beta2 version but I get exactly the same issue. Fine on local, breaks with same error on Jenkins. The stack trace suggests it's an issue with the chalk package that Jest uses, not with any of the tests that are being run. |
It's not an issue with chalk, it's because you have left dangling async code on a sync test (or you haven't waited for all stuff on an async test). Line 72 of require('ansi-styles').color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g'); However, your test has already finished, meaning the environment has been disposed, and any further call to |
Ah, I understand! Thanks very much for the explanation, @mjesun |
I am seeing this same thing as well while running latest CRA EDIT |
I was getting a similar error, trying to report that I had no tests. allowed the loading to complete, and get the expected error (but annoying) error about no tests. This is something jest could do for itself, though I'm not sure what uses might depend on it NOT doing it. |
I had this issue because another module was installing |
@th317erd You have saved my day. I am totally grateful. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug Report
Attempting to run Jest (via
yarn run test:ci
) in container as part of Jenkins pipeline. Works flawlessly on local machine, but fails randomly on Jenkins. About half of identical builds are coming back with the following error.Jest configuration
The text was updated successfully, but these errors were encountered: