Requiring modules with isolateModules does not work if module has already been required with a non-isolated method e.g: using require.
See original GitHub issue🐛 Bug Report
Requiring modules with isolateModules does not work if module has already been required with a non-isolated method e.g: using require.
To Reproduce
describe('Isolated modules test', () => {
test('should be able to return different isolated modules', () => {
let m0 = require('../path/to/testing/module')
// let m0
// jest.isolateModules(() => {
// m0 = require('../path/to/testing/module')
// })
let m1
jest.isolateModules(() => {
m1 = require('../path/to/testing/module')
})
expect(m1).toStrictEqual(m0) // does not fail, while it should.
})
})
Expected behavior
Requiring a module should not have an affect to an isolated module registry.
describe('Isolated modules test', () => {
test('should be able to return different isolated modules', () => {
let m0 = require('../path/to/testing/module')
// let m0
// jest.isolateModules(() => {
// m0 = require('../path/to/testing/module')
// })
let m1
jest.isolateModules(() => {
m1 = require('../path/to/testing/module')
})
expect(m1).toStrictEqual(m0) // should fail.
})
})
Run npx envinfo --preset jest
npx: installed 1 in 2.159s
System:
OS: macOS 10.14.1
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Binaries:
Node: 8.15.0 - ~/.nvm/versions/node/v8.15.0/bin/node
Yarn: 1.9.4 - ~/.yarn/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.15.0/bin/npm
npmPackages:
jest: ^24.1.0 => 24.1.0
Issue Analytics
- State:
- Created 5 years ago
- Reactions:11
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Why is jest.isolateModules not working as expected?
I want to move away from using jest.resetModules since I want to reset two modules, but keep one through all the runs.
Read more >[Amendment] SE-0306: Actors and `nonisolated let`
Hi everyone. We are starting review for an amendment to the accepted proposal SE-0306: Actors today, and running the review through May 28, ......
Read more >Installation Manual of Solar Module2022
Do not operate when modules are wet unless you wear PPE(personal protective equipment). Please follow the cleaning requirements in this manual when cleaning ......
Read more >AB_1794_Series_Datasheet.pdf - ArtisanTG
If desired, connect individual power supplies to each base to isolate modules. Plug the I/O module into the terminal base to connect the...
Read more >LT0351 4100ES Fire Indicator Panel Operator's Manual
not require entry of a passcode. ZONE ISOLATIONS - The zone isolate status is not stored in non-volatile memory, so if the panel...
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
I also ran into this. My use case is:
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. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.