The Wire · Showcase
JEST FIXES MODULE CACHING BUG THAT BREAKS VIRTUAL MOCKS
By RepoJournal · Filed · About Meta
Jest's resolver was silently losing track of virtual mock state, causing test isolation failures and cache collisions across parallel workers.
The core issue: `Resolver._moduleIDCache` keyed lookups by importer, module, and options, but omitted whether that specific lookup was registered as a virtual mock [1]. That meant two different virtual mock states could collide in the cache, breaking test isolation. JasonColapietro's fix includes each requested module's virtual-mock state in the cache key itself, plus a two-suite end-to-end regression that runs both test files in one worker to lock in the fix [1]. On the interop front, Jest now correctly handles ESM exports like `export { myVariable as "module.exports" }` to match Node's CommonJS compatibility layer [2]. Meanwhile, watch mode on Windows was crashing when `git maintenance` or other processes held file locks, surfacing as `EPERM` errors that Jest couldn't tolerate [3]. The watcher now treats `EPERM` on Windows the same way it treats `ENOENT` anywhere else: recoverable and survivable [3]. React Native continues mechanically converting Objective-C push notification and image store modules to TurboModule specs, with hand-reconciliation of type mismatches along the way [4] [5].
One email a day. Unsubscribe in one click.
Keep up with Meta in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.
One email a day. Unsubscribe in one click. Read a past issue →
Action items
- → Pull Jest main to catch the virtual mock cache isolation fix before your next test run facebook/jest [immediate]
- → Monitor Windows watch mode stability; the EPERM tolerance fix is in flight facebook/jest [monitor]
- → Plan React Native upgrade when TurboModule conversions land; manual type reconciliation is complete facebook/react-native [plan]
References
- [1] fix(jest-resolve): isolate virtual mock module IDs ↗ facebook/jest
- [2] fix(cjs-esm-interop): support `module.exports` in ESM ↗ facebook/jest
- [3] fix(jest-haste-map): tolerate transient EPERM in the watcher lstat ↗ facebook/jest
- [4] xplat/js/react-native-github/packages/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.mm (#57833) facebook/react-native
- [5] xplat/js/react-native-github/packages/react-native/Libraries/Image/RCTImageStoreManager.mm (#57842) facebook/react-native