From 2c2d59b84d489f565574c17132a6953001dce6f1 Mon Sep 17 00:00:00 2001 From: Luke Page Date: Wed, 19 May 2021 07:57:59 +0200 Subject: [PATCH 1/2] Additional fix for #4444 to prevent errors on windows --- packages/jest-transform/src/ScriptTransformer.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/jest-transform/src/ScriptTransformer.ts b/packages/jest-transform/src/ScriptTransformer.ts index dca4aa3492ba..f15cf8304e86 100644 --- a/packages/jest-transform/src/ScriptTransformer.ts +++ b/packages/jest-transform/src/ScriptTransformer.ts @@ -933,6 +933,12 @@ const readCacheFile = (cachePath: Config.Path): string | null => { try { fileData = fs.readFileSync(cachePath, 'utf8'); } catch (e) { + // on windows write-file-atomic is not atomic which can + // result in this error + if (e.code === 'ENOENT' && process.platform === 'win32') { + return null; + } + e.message = 'jest: failed to read cache file: ' + cachePath + From 37697cf29d85c502a2bc4ffc4d080440879b27fe Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Wed, 28 Sep 2022 09:11:59 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88cfba26a809..585a9d0eb100 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - `[jest-haste-map]` Remove `__proto__` usage ([#13256](https://github.com/facebook/jest/pull/13256)) - `[jest-mock]` Improve `spyOn` typings to handle optional properties ([#13247](https://github.com/facebook/jest/pull/13247)) - `[jest-snapshot]` Throw useful error when an array is passed as property matchers ([#13263](https://github.com/facebook/jest/pull/13263)) +- `[jest-transform]` Attempt to work around issues with atomic writes on Windows ([#11423](https://github.com/facebook/jest/pull/11423)) ### Chore & Maintenance