Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vidarc opened this issue Sep 14, 2021 · 5 comments · Fixed by #11882
Closed

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

vidarc opened this issue Sep 14, 2021 · 5 comments · Fixed by #11882

Comments

@vidarc
Copy link

vidarc commented Sep 14, 2021

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: #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
@rburgst
Copy link

rburgst commented Sep 16, 2021

have the same problem with ts-jest, here is a repro repo https://github.com/rburgst/ts-jest-27.1

@SimenB
Copy link
Member

SimenB commented Sep 16, 2021

Please put together a minimal repository showing the error (i.e. without ts-jest - I have zero clue what mocked is). Ideally without typescript etc either

@SimenB
Copy link
Member

SimenB commented Sep 16, 2021

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

@SimenB
Copy link
Member

SimenB commented Sep 20, 2021

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants