From 7628207fd2e11947e05757a3bf842631f46820b1 Mon Sep 17 00:00:00 2001 From: Dmitri Date: Fri, 21 Jul 2023 13:17:55 +0300 Subject: [PATCH] fix: incorrectly setting the name of currently running concurrent test (#14335) --- CHANGELOG.md | 1 + packages/jest-circus/src/run.ts | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e7e2690d1c7..461f20949ee2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fixes +- `[jest-circus]` Fix snapshot matchers in concurrent tests when nr of tests exceeds `maxConcurrency` ([#14335](https://github.com/jestjs/jest/pull/14335)) - `[jest-snapshot]` Move `@types/prettier` from `dependencies` to `devDependencies` ([#14328](https://github.com/jestjs/jest/pull/14328)) ### Chore & Maintenance diff --git a/packages/jest-circus/src/run.ts b/packages/jest-circus/src/run.ts index ea6d5eb3076f..6564b92e8c45 100644 --- a/packages/jest-circus/src/run.ts +++ b/packages/jest-circus/src/run.ts @@ -140,9 +140,8 @@ function startTestsConcurrently(concurrentTests: Array) { jestExpect.setState({currentConcurrentTestName: testNameStorage}); for (const test of concurrentTests) { try { - const promise = testNameStorage.run(getTestID(test), () => - mutex(test.fn), - ); + const testFn = test.fn; + const promise = mutex(() => testNameStorage.run(getTestID(test), testFn)); // Avoid triggering the uncaught promise rejection handler in case the // test fails before being awaited on. // eslint-disable-next-line @typescript-eslint/no-empty-function