Jest 27 errors with `ReferenceError: setImmediate is not defined`
See original GitHub issueProblem
While upgrading to 27.0.3 of jest, I have failing integration tests because
● Test suite failed to run
ReferenceError: setImmediate is not defined
at Parser.destroy (../../../node_modules/@prisma/client/runtime/index.js:25498:7)
at detachSocket (../../../node_modules/@prisma/client/runtime/index.js:25536:21)
at Socket.onSocketClose (../../../node_modules/@prisma/client/runtime/index.js:25545:5)
Suggested solution
Because setImmediate is a non-standard API in the first place, and only officially supported by ie10, prisma should remove references to it.
Sorry if this is the wrong report time, I was split between a feature request and a bug.
Issue Analytics
- State:
- Created 2 years ago
- Comments:23 (1 by maintainers)
Top Results From Across the Web
Jest Test Error: browserType.launch: setImmediate is not ...
I just added the polyfill.js in my test class : import 'core-js'; after that setImmediate was defined again and works now as intended....
Read more >spyon is not defined jest | The AI Search Engine You Control
ReferenceError : spyOn is not defined. So changed it to jest.spyOn but now I am getting the error: Property 'and' does not exist...
Read more >Jest 27: New Defaults for Jest, 2021 edition
We introduced a few more small breaking changes to help you avoid mistakes by disallowing some things that can easily happen unintentionally:.
Read more >How to resolve the Jest test error 'browsertype.launch - Quora
launch: setimmediate is not defined" while using Playwright (JavaScript, Jest.js, Playwright, development)?.
Read more >jest-environment-jsdom | Yarn - Package Manager
Jest will set process.env.NODE_ENV to 'test' if it's not set to something else. You can use that in your configuration to conditionally setup...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you are actually using
setImmediatein your tests, but your test environment is actuallyjsdom, the cleanest approach is to simply import the dependency. Just add this at the top:I had the same issue after updating to
jest v27. For those who could not solve with any of the previous responses (like me). After some research I’ve solved with:jest.config.jsjest.env.js