Skip to content

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

@maayanbar13

Description

@maayanbar13

🐛 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions