Comments (4)
can you put together a reproduction? setImmediate
is only available in Node env, so I assume the issue is simply that you are using JSDOM env. Hard to say without a reproduction, tho 🙂
from fake-timers.
Yeah, I have been looking at this for the last ten minutes and think it comes down to something related to what @SimenB says. Hard to look into without a repro.
If you look for setImmediatePresent
in the code, you will see that that timer is only ever added if it is present in the environment, advancing timers or not: https://github.com/sinonjs/fake-timers/blob/main/src/fake-timers-src.js#L998.
So it might be something related to what _global
refers to that causes this. Maybe _global
is bound to different things due to something I cannot immediately see (related to JSDom and async behavior)?
from fake-timers.
can you put together a reproduction?
setImmediate
is only available in Node env, so I assume the issue is simply that you are using JSDOM env. Hard to say without a reproduction, tho 🙂
yep. I updated the jest.config.ts and things started to work.
import type {
Config,
} from 'jest';
const integrationTestConfig: Config = {
preset: 'ts-jest',
testEnvironment: 'node',
// testEnvironment: 'jsdom', -- results in the error
testMatch: [
'**/*.integration.spec.ts',
],
collectCoverageFrom: [
'./packages/**/src/*.ts',
],
};
export default integrationTestConfig;
Thank you!
from fake-timers.
Thank you again!
from fake-timers.
Related Issues (20)
- Test failing since Node 18.8.0 HOT 2
- `runToLastAsync` doing infinite loop when `now` is specified to setup clock
- [Feature] Jump forward in time to simulate throttled timers HOT 22
- requestAnimationFrame is passed incorrect argument HOT 8
- [Feature]: Speed up all fake timers HOT 12
- [Feature]: In Node, hijack perf_hooks.performance in addition to global.performance HOT 5
- TypeError Since Node 19 HOT 4
- NodeJS "timers" module is not mocked HOT 17
- Calls to `tick()` do not cause all setTimeouts to fire in specific scenarios. HOT 6
- Mock "timers/promise" module HOT 2
- NodeJS `timers` module mock causing tests to timeout in JSDom HOT 3
- process.hrtime gives incorrect results HOT 4
- Leave global scope untouched HOT 5
- How should `shouldAdvanceTime` work together with `Date`? HOT 1
- runAllAsync and runToLastAsync do not run code in the microtask queue HOT 5
- Cleanly switch to real time and back again to fake time while testing HOT 2
- Skypack bundle cannot be loaded in the browser HOT 5
- `install({ toFake: ["setImmediate"] })` fails when `setImmediate` is not available in context (such as browser environment) HOT 5
- Support performance.measure method
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fake-timers.