When running in Jest, code assumes `setImmediate` and `clearImmediate`
See original GitHub issue@testing-library/dom
version: 7.29.6- Testing Framework and version: Jest@https://github.com/facebook/jest/pull/11222
- DOM Environment: JSDOM@16.4.0
Relevant code or config:
require('@testing-libray/react')
What you did:
Ran the test without global setImmediate
and clearImmediate
defined
What happened:
Reproduction:
See https://github.com/facebook/jest/pull/11222. Essentially, delete setImmediate
and clearImmediate
from global
in the JSDOM env Jest sets up.
Problem description:
It throws runtime errors at require
/import
-time
Suggested solution:
Do a typeof setImmediate !== 'undefined'
before using it.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:12 (8 by maintainers)
Top Results From Across the Web
дэн on Twitter: "A fix in React is blocked by a fix in Jest, which ...
When running in Jest, code assumes `setImmediate` and `clearImmediate` · Issue #914 · testing-lib... @testing-library/dom version: 7.29.6 Testing Framework ...
Read more >Jest: tests can't fail within setImmediate or process.nextTick ...
But you create a promise, and even you resolve it in the test it will have no effect in the test run, you...
Read more >jest 27 setimmediate is not defined - (주)이글벳
Instructs Jest to use fake versions of the standard timer functions (setTimeout, setInterval, clearTimeout, clearInterval, nextTick, setImmediate and ...
Read more >Configuring Jest
Jest will run .mjs and .js files with nearest package.json 's type field set to module as ECMAScript Modules.
Read more >CoCalc -- FakeTimers-test.js
This source code is licensed under the BSD-style license found in the ... it('mocks clearImmediate if setImmediate is on global', function() {.
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
@renatoalencar is it possible to switch the
setImmediate
in favour ofsetTimeout(()=> observer.disconnect(), 0)
inwaitForDomChange
implementation ?I’m currently trying to see if there’s any way to break this, and actually works just fine. Let me do some more tests and see.