question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: issue with jest-runtime between 27.1.0 and 27.1.1 and jest.isolateModules

See original GitHub issue

Version

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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

2reactions
SimenBcommented, Sep 16, 2021

Actually never mind, just ripping it out wasn’t too bad - fix incoming 🙂

0reactions
github-actions[bot]commented, Oct 21, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found