diff --git a/.nx/version-plans/version-plan-1792138223000.md b/.nx/version-plans/version-plan-1792138223000.md new file mode 100644 index 00000000..2f6a9c83 --- /dev/null +++ b/.nx/version-plans/version-plan-1792138223000.md @@ -0,0 +1,5 @@ +--- +__default__: patch +--- + +Harness runs use less CPU. Jest now builds its file map in a single process instead of starting a pool of worker processes on every cold start or file change, and it no longer indexes Harness's `.harness` cache or iOS and Android build output (`ios/Pods`, `ios/build`, `android/build`, `android/.gradle`, `android/app/build`, `android/app/.cxx`). Jest also finds files without watchman, which is now faster than querying it; Metro still uses watchman. diff --git a/packages/jest/src/jest-preset.ts b/packages/jest/src/jest-preset.ts index 8725af39..66a05e15 100644 --- a/packages/jest/src/jest-preset.ts +++ b/packages/jest/src/jest-preset.ts @@ -1,3 +1,21 @@ export default { runner: '@react-native-harness/jest', + // Tests run serially on the device, so Jest only uses its workers to build + // the haste map. On a cold cache or after any file change that starts a pool + // of `availableParallelism() - 1` processes, which roughly doubles Jest's + // CPU time without making the run faster. + maxWorkers: 1, + // Build and cache output never contains tests, but it can hold tens of + // thousands of files. Jest checks these patterns before descending into a + // directory, so its crawl skips them entirely. Jest appends a project's own + // patterns to the preset's. + modulePathIgnorePatterns: [ + '/\\.harness(/|$)', + '/ios/(Pods|build)(/|$)', + '/android/(build|\\.gradle|app/build|app/\\.cxx)(/|$)', + ], + // With the build output skipped, Jest's own crawl is cheaper than querying + // watchman, which costs two CLI process spawns per run and still lists every + // file. Metro keeps using watchman. + watchman: false, };