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

When an expect call fails inside jest.isolateModules the sandbox doesn't get unloaded #9536

Closed
maayanbar13 opened this issue Feb 7, 2020 · 4 comments · Fixed by #9541
Closed

Comments

@maayanbar13
Copy link

🐛 Bug Report

When a test fails inside jest.isolateModules callback, the sandbox registry doesn't close, causing all other tests using isolateModules to fail.

To Reproduce

it("Should fail", () => {
  jest.isolateModules(() => {
    expect(true).toBe(false);
  });
});

it("Should pass", () => {
  jest.isolateModules(() => {
    expect(true).toBe(true);
  });
});

Expected behavior

Should fail the first tests, but the other test should pass.

Link to repl or repo (highly encouraged)

https://repl.it/@maayanbar/Jest-isolateModules

envinfo

  System:
    OS: Windows 10 10.0.18362
    CPU: (8) x64 Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz
  Binaries:
    Node: 12.12.0 - D:\Program Files\nodejs\node.EXE
    Yarn: 1.19.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.11.3 - D:\Program Files\nodejs\npm.CMD
@maayanbar13 maayanbar13 changed the title When a an expect call fails inside jest.isolateModules the sandbox doesn't get unloaded When an expect call fails inside jest.isolateModules the sandbox doesn't get unloaded Feb 7, 2020
@jeysal
Copy link
Contributor

jeysal commented Feb 7, 2020

Oh, what an oversight! Looks like there's just a try-finally missing that should be in the implementation of isolateModules in jest-runtime (unless I'm missing something that makes it more complicated). PRs welcome!

@doniyor2109
Copy link
Contributor

Hi @jeysal. Can I work on this issue?

@SimenB
Copy link
Member

SimenB commented Feb 9, 2020

@doniyor2109 please go for it 🙂

@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 May 11, 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.

4 participants