Closed
Description
Version
29.6.2
Steps to reproduce
Steps to reproduce:
- Clone https://github.com/patrickdawson/jestIsolateModulesAsyncBug.git
- npm install
- npm run test
Test shows the error
Expected behavior
In this testcase
it('should have a fresh module state in each isolateModulesAsync context', async () => {
await jest.isolateModulesAsync(async () => {
const { getState, incState } = await import('../src/main.js');
expect(getState()).toBe(0);
incState();
expect(getState()).toBe(1);
});
await jest.isolateModulesAsync(async () => {
const { getState, incState } = await import('../src/main.js');
expect(getState()).toBe(0);
incState();
expect(getState()).toBe(1);
});
});
I expect according to the docs https://jestjs.io/docs/jest-object#jestisolatemodulesasyncfn that each isolateModulesAsync
context has its own 'fresh" module so all module variables should be in the intial state. The test shows that this is not the case
Actual behavior
The state of the previous isolateModulesAsync
context affects the second scope.
Additional context
No response
Environment
System:
OS: Windows 11 22H2 (Build 22621.1992)
CPU: 12th Gen Intel(R) Core(TM) i9-12900K, 3200 MHz, 16 Core, 24 logical cores
Binaries:
Node: 18.17.2
npm: 9.6.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment