From f3c48b52ffd9086e9848d742009068c8f6d5881c Mon Sep 17 00:00:00 2001 From: Oliver Salzburg Date: Fri, 18 Feb 2022 10:54:59 +0100 Subject: [PATCH] fix(haste-map): multiple resolutions on failure (#12420) --- CHANGELOG.md | 1 + packages/jest-haste-map/src/crawlers/node.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b0ea9c4eec4..01f3284eb17e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ - `[jest-config]` Correctly detect CI environment and update snapshots accordingly ([#12378](https://github.com/facebook/jest/pull/12378)) - `[jest-config]` Pass `moduleTypes` to `ts-node` to enforce CJS when transpiling ([#12397](https://github.com/facebook/jest/pull/12397)) - `[jest-environment-jsdom]` Make `jsdom` accessible to extending environments again ([#12232](https://github.com/facebook/jest/pull/12232)) +- `[jest-haste-map]` Don't use partial results if file crawl errors ([#12420](https://github.com/facebook/jest/pull/12420)) - `[jest-jasmine2, jest-types]` [**BREAKING**] Move all `jasmine` specific types from `@jest/types` to its own package ([#12125](https://github.com/facebook/jest/pull/12125)) - `[jest-matcher-utils]` Pass maxWidth to `pretty-format` to avoid printing every element in arrays by default ([#12402](https://github.com/facebook/jest/pull/12402)) diff --git a/packages/jest-haste-map/src/crawlers/node.ts b/packages/jest-haste-map/src/crawlers/node.ts index 9ef1800772b4..17527e695ebc 100644 --- a/packages/jest-haste-map/src/crawlers/node.ts +++ b/packages/jest-haste-map/src/crawlers/node.ts @@ -71,7 +71,9 @@ function find( fs.readdir(directory, {withFileTypes: true}, (err, entries) => { activeCalls--; if (err) { - callback(result); + if (activeCalls === 0) { + callback(result); + } return; } entries.forEach(entry => {