From e6ec2b30910734cfdf68e153bc07ba7cc86f6577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mar=C3=A9chal=20Eliot?= Date: Mon, 10 Feb 2020 14:57:45 +0100 Subject: [PATCH 1/2] Fix routes on Windows I noticed that on Windows, if you had one bad route in your jest.config.js, it would return 0 route found. It looked like a bug to me, because this was not what happened on Linux, and there was no error message directly saying a route was wrong. This simple fix ensure that all routes are checked and registered in the result array before returning anything to callback. What was happening is that the calls being asynchronous and the error check being at the beginning, when it encountered a bad route, it would return the callback and ignore the other route, wich could be ok. --- packages/jest-haste-map/src/crawlers/node.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/jest-haste-map/src/crawlers/node.ts b/packages/jest-haste-map/src/crawlers/node.ts index 833f51f80f14..ac1474e96280 100644 --- a/packages/jest-haste-map/src/crawlers/node.ts +++ b/packages/jest-haste-map/src/crawlers/node.ts @@ -35,7 +35,9 @@ function find( fs.readdir(directory, {withFileTypes: true}, (err, entries) => { activeCalls--; if (err) { - callback(result); + if (activeCalls === 0) { + callback(result); + } return; } // node < v10.10 does not support the withFileTypes option, and From fedf75a0a4480ee72c72b1bb16dc956bda71c7a1 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Mon, 10 Feb 2020 15:19:28 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3376f7ee7dd..7c8996c10fc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ ### Fixes - `[jest-config]` Treat `setupFilesAfterEnv` like `setupFiles` when normalizing configs against presets ([#9495](https://github.com/facebook/jest/pull/9495)) +- `[jest-haste-map]` Return correctly from crawler if `readdir` errors ([#9549](https://github.com/facebook/jest/pull/9549)) - `[jest-matcher-utils]` Fix diff highlight of symbol-keyed object. ([#9499](https://github.com/facebook/jest/pull/9499)) - `[jest-resolve]` Fix module identity preservation with symlinks and browser field resolution ([#9511](https://github.com/facebook/jest/pull/9511)) - `[jest-resolve]` Do not confuse directories with files ([#8912](https://github.com/facebook/jest/pull/8912))