Created by: JReinhold
Fixes #2687 (closed) .
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
-
Test that it breaks without modification - Don't modify anything.
- Add
"jest": { "cacheDirectory": "tmp/jest-cache" }
to/packages/react-scripts/package.json
- Run
yarn test
- See that it complaints about overriding
cacheDirectory
-
Test that it works with modified code - Add modification to code
- Repeat above
- See that it doesn't complain
- See that a new folder
tmp/jest-cache
is created in/packages/react-scripts/template/
- Re-run tests
- See that it still works
-
Test that it works in generated app - run
yarn create-react-app a-test-app
- Repeat above steps in the newly generated app
- See that it still works
- run
Documentation
I've added cacheDirectory
to the list of supported overrides in the template README.md. I've also added resetMocks
, resetModules
and watchPathIgnorePattern
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.