Skip to content

Hot runtime: matchers added with expect.extend in one file stay for later files #808

Open

Description

@danfry1

Under hotRuntime, including freshRuntime: true, a matcher a test file adds with expect.extend stays available in every later file on the same worker. Under per-file isolation, each file starts with only the matchers its setup files add.

Repro: two files run in order on one worker.

// a.test.ts
expect.extend({ toBeX: () => ({ pass: true, message: () => "" }) });

// b.test.ts
expect(1).toBeX(); // per-file isolation: "Invalid Chai property: toBeX"; hot: passes

expect and chai are resident test-runtime packages, so a registration made during one file survives the per-file reset. Matchers registered in setup files are unaffected, because those run again for every file. The impact is a file that passes only because an earlier file on its worker registered a matcher it never registers itself.

Either restore the matcher set at each file boundary, or document it as a known difference.

Activity

  1. added this to the 0.16.0 milestone on Nov 14, 2026
  2. added
    bug
    area:hot-runtime
    priority:low
    on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:hot-runtimebugpriority:low

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions