-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Enable jest cacheDirectory configuration #3860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Heya @JReinhold I've just stumbled across this whilst trying to set this up to speed up our CI builds. I had assumed this was already an option as it's listed in the docs (https://facebook.github.io/jest/docs/en/configuration.html#cachedirectory-string). Would you happen to know how it got there without this being merged? If it means anything, this will be super helpful for us. Not just for the CI speed up, but because we are trying to debug a really painful edgecase to do with transformers that only occurs in CI and only very occasionally, this will help us zip up the cached transformed files and upload to s3 when it fails. |
Oh.. To make this even stranger, I found this because it looked like it wasn't working for me locally but it turned out it did work, my editor was just not indexing node_modules
And sure enough, I can see the cache in that directory. Tested in CI and got pretty great results too! (6:55min -> 2:25min to run around 6k tests) I'm using
if that helps. |
@lukebatchelor this might be a stupid question, but do you realize that this is a PR for |
You are 1000% correct. I was very confused, hahaha. Thanks! |
Fixes #2687 .
Enables the user to override Jest's
cacheDirectory
configuration, mainly to make it easier for users to speed up their builds on CI, by caching jest's cache in between builds.How I tested
"jest": { "cacheDirectory": "tmp/jest-cache" }
to/packages/react-scripts/package.json
yarn test
cacheDirectory
tmp/jest-cache
is created in/packages/react-scripts/template/
yarn create-react-app a-test-app
Documentation
I've added
cacheDirectory
to the list of supported overrides in the template README.md. I've also addedresetMocks
,resetModules
andwatchPathIgnorePattern
as they weirdly wasn't on the list, even though the are supported. If they are omitted on purpose, I'm sorry, I'll remove them again.I've also added a short section about using the
cacheDirectory
option to speed up tests on CI.Future work
Should this be accepted, I'll gladly looking into speeding up this repos tests using the
cacheDirectory
pattern. However I'm inexperienced with TravisCI so I might come up short. Please let me know in the comments if I should pursue this or not.