Repository navigation
[No QA] One Weird Trick To Make Your Jest Suite 10x Faster - #92720
Merged
Merged
Conversation
chuckdries
force-pushed
the
chuckdries/jest-ci-cache
branch
from
June 4, 2026 17:56
8948733 to
aaa49c0
Compare
Contributor
Author
|
|
Contributor
Author
|
OK! First SessionTest run passed after 169 seconds link. Restarting, expecting it to be much faster 🤞 |
Contributor
Author
|
Vindication! SessionTest took only 14s on second run! link |
roryabraham
approved these changes
Jun 4, 2026
Contributor
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
Contributor
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Contributor
|
🚀 Deployed to staging by https://github.com/roryabraham in version: 9.4.0-0 🚀
Bundle Size Analysis (Sentry): |
Contributor
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.4.0-7 🚀
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
This PR improves our jest cache keying, significantly speeding up runs (especially the SessionTest that has been timing out a lot on main)
SessionTest.tsxsuiteTime:)The unit test workflow runs across 8 parallel shards, and every shard restors the Jest transform cache (
.jest-cache) using the same constant key,${{ runner.os }}-jest.Each shard only runs ~1/8 of the test suites, so each one instruments and caches a different subset of files. Because the key was identical for all shards and
actions/cachekeys are immutable (a cache is only uploaded on a miss of the exact key, and never overwritten afterward), the first shard to finish froze its partial cache underLinux-jest. Every run since restored that same partial cache — aCache hitof only ~69 MB, versus ~2.2 GB for a complete local cache (at least on my machine).When a shard restores a cache that is missing the instrumented output for the files it needs, Jest re-instruments those files inline on first
require. For the shard that runstests/ui/SessionTest.tsx, that means paying the fullbabel-plugin-istanbulinstrumentation cost for the entire<App/>import graph during the test itself. Measured locally: a warm cache runs this suite in ~13s, a cold cache in ~172s. This is why I think it times out.This PR scopes the cache key per shard and makes it content-aware:
matrix.chunk) so each shard caches the files it actually runs, instead of inheriting another shard's partial subset.package-lock.json+babel.config.jsso the cache refreshes when dependencies or Babel/instrumentation config change, instead of being frozen forever.restore-keysso that when the hash changes the run still restores the shard's previous cache as a warm base; Jest's own per-file content hashing then re-transforms only the files that actually changed, and the post-job step saves the updated complete cache under the new key. Steady state stays warm — a dependency bump does not cause a fully cold run.SessionTest(and any other heavy full-<App/>suite) runs against warm instrumented output instead of paying the cold cost inline.Fixed Issues
$
PROPOSAL:
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari