[Bug]: issue with jest-runtime between 27.1.0 and 27.1.1 and jest.isolateModules
See original GitHub issueVersion
27.2.0
Steps to reproduce
unable to link my repo, but can give an example that currently works. seems how mocks are applied changed between 27.1.0 and 27.1.1. assume related to this PR: https://github.com/facebook/jest/pull/11818
Expected behavior
const someModule = require('some-module');
jest.mock('some-module')
describe('test', () => {
let app;
beforeEach(() => {
jest.isolateModules(() => {
app = require('./app.js')
})
})
test('expect module to have been called', () => {
expect(someModule.function).toHaveBeenCalled();
})
})
I would expect this to pass, which is currently does if I pass in a yarn resolution to downgrade jest-runtime
to version 27.1.0
.
Actual behavior
Using above example, the instance of some-module
inside of the test and inside the required file appear to be different. Inside the file, the module is indeed mocked, but the expectation does not pass.
Additional context
No response
Environment
System:
OS: macOS 11.5.2
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Binaries:
Node: 14.17.6 - /usr/local/bin/node
Yarn: 1.22.11 - /usr/local/bin/yarn
npm: 7.21.1 - /usr/local/bin/npm
npmPackages:
jest: 27.2.0 => 27.2.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Jest 27: New Defaults for Jest, 2021 edition
We will explain those changes of defaults and other notable breaking changes in this post, but first, let's get into some exciting new...
Read more >jest v27.2.0へのアップデートで発生した不具合の回避方法 ...
[Bug]: issue with jest-runtime between 27.1.0 and 27.1.1 and jest.isolateModules · Issue #11873 · facebook/jest.
Read more >jest-runtime | Yarn - Package Manager
Fixed change events to be emitted in jest-haste-map's watch mode. This fixes issues with Jest's new watch mode and react-native-packager. Fixed cli arguments...
Read more >How to test throwing error from module root (not method)
I want to describe this in specification (test), using Jest framework and test the feature. Here is simplified reproduced example:
Read more >[错误]:在27.1.0和27.1.1和JEST.ISOLAteModules之间的Jest ...
[Bug]: issue with jest-runtime between 27.1.0 and 27.1.1 and jest.isolateModules. 版本. 27.2.0. 重现. 的步骤无法链接我的repo,但可以给出当前工作的示例。
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 FreeTop 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
Top GitHub Comments
Actually never mind, just ripping it out wasn’t too bad - fix incoming 🙂
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.