question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow specifying jest's `cacheDirectory`

See original GitHub issue

Hi, this proposal is related to issue https://github.com/facebook/jest/issues/3705 (jest cache is not handled correctly upon moving files from point A to point B. This eventually causes coverage information to be displayed incorrectly).

For this reason, it would be nice to have a way to clear the jest cache manually when required. In order to do that, it would be useful to have a way to set the cache directory.

This is possible in Jest by setting the cacheDirectory config option in package.json (or from the command line). Unfortunately, in an application created with create-react-app, this config option is among those which cannot be overridden:

Out of the box, Create React App only supports overriding these Jest options:

  • collectCoverageFrom
  • coverageReporters
  • coverageThreshold
  • snapshotSerializers.

These options in your package.json Jest configuration are not currently supported by Create React App:

  • cacheDirectory

Without being able to set cacheDirectory, the cache files are created in a random-looking temporary directory such as /private/var/folders/zj/112vf5bj0js_hx6l9ntz3w780000gn/T/jest_dx (at least on my Mac Os X Sierra machine).

I think it would be useful to be able to set cacheDirectory to something more predictable, such as ./node_modules/.cache/jest, or even ./.cache/jest.

What do you think?

Thanks in advance for this awesome tool!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
cpojercommented, Jul 3, 2017

Watchman picks it up, it has to be ignored globally, I managed to publish some private cache to npm at some point, all these kinda things. Since we moved it to tmp, we didn’t have a problem with it at FB.

2reactions
gaearoncommented, Jul 3, 2017

We already store Babel cache in node_modules/.cache so we might as well do the same for Jest. But I’d love to learn more about:

We used to store it inside of Jest but it was always a huge issue to people

Can you research why it was an issue before? cc @cpojer

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring Jest
Setting bail to true is the same as setting bail to 1 . cacheDirectory [string]​. Default: "/tmp/<path>". The directory where Jest should store ......
Read more >
Configuring package.json · Jest
cacheDirectory [string] # ... The directory where Jest should store its cached dependency information. Jest attempts to scan your dependency tree once (up-front) ......
Read more >
Timthumb can't show image after it's uploaded - Stack Overflow
Changing the "cache" directory permission to 777; Deleting index.html file in the "cache" directory. Try that, it should work.
Read more >
Configuring Jest compiled - w3resource
These options enable you to control Jest's behavior in your ... When globs or paths are specified alongside global, coverage data for ...
Read more >
7 Github Actions Tricks I Wish I Knew Before I Started
In this case, you'd probably want to give the code some time to “cook” in main or develop before you ... name: Get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found