Skip to content

Commit 4adf6ab

Browse files
authored
Additional fix for #4444 to prevent errors on windows (#11423)
1 parent 0c15eb6 commit 4adf6ab

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
- `[jest-mock]` Improve `spyOn` typings to handle optional properties ([#13247](https://github.com/facebook/jest/pull/13247))
1818
- `[jest-snapshot]` Throw useful error when an array is passed as property matchers ([#13263](https://github.com/facebook/jest/pull/13263))
1919
- `[jest-snapshot]` Prioritize parser used in the project ([#13323](https://github.com/facebook/jest/pull/13323))
20+
- `[jest-transform]` Attempt to work around issues with atomic writes on Windows ([#11423](https://github.com/facebook/jest/pull/11423))
2021

2122
### Chore & Maintenance
2223

packages/jest-transform/src/ScriptTransformer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,12 @@ const readCacheFile = (cachePath: string): string | null => {
946946
try {
947947
fileData = fs.readFileSync(cachePath, 'utf8');
948948
} catch (e: any) {
949+
// on windows write-file-atomic is not atomic which can
950+
// result in this error
951+
if (e.code === 'ENOENT' && process.platform === 'win32') {
952+
return null;
953+
}
954+
949955
e.message = `jest: failed to read cache file: ${cachePath}\nFailure message: ${e.message}`;
950956
removeFile(cachePath);
951957
throw e;

0 commit comments

Comments
 (0)