Skip to content

Files

Latest commit

 

History

History
33 lines (25 loc) · 803 Bytes

require-local-test-context-for-concurrent-snapshots.md

File metadata and controls

33 lines (25 loc) · 803 Bytes

Pattern: Missing test context in concurrent snapshot tests

Issue: -

Description

Running snapshot tests concurrently without proper test context can lead to unreliable or inconsistent results. Using local test context ({ expect } or context) ensures snapshots remain accurate and stable when running tests in parallel.

Examples

Example of incorrect code:

test.concurrent("myLogic", () => {
  expect(true).toMatchSnapshot();
});

describe.concurrent("something", () => {
  test("myLogic", () => {
    expect(true).toMatchInlineSnapshot();
  });
});

Example of correct code:

test.concurrent("myLogic", ({ expect }) => {
  expect(true).toMatchSnapshot();
});

test.concurrent("myLogic", (context) => {
  context.expect(true).toMatchSnapshot();
});