rules_jest icon indicating copy to clipboard operation
rules_jest copied to clipboard

[FR]: Default cacheDirectory to TEST_TMPDIR

Open sallustfire opened this issue 1 year ago • 1 comments

What is the current behavior?

Jest provides a config option cacheDirectory which specifies where intermediate file system outputs are written such as transformations or haste map. If left unspecified, the default is approximately ${os.tmpdir()}/jest_${process.uid}. The contents of this directory are not deleted when jest exits and files are written even when --no-cache is set.

Describe the feature

Bazel's TEST_TMPDIR should be integrated to set the jest cacheDirectory in the generated configuration.

  • TEST_TMPDIR in Bazel is available to every test action as an ENV. The directory is writable, guaranteed to be empty, and unique to a given test target.
  • This enforces hermeticity at the file system level between different jest_test targets and brings rules_jest more in line with the bazel test specification.
  • TEST_TMPDIR can either be provided via CLI flag via "make variable" expansion or set in the generated config template by reading from process.env.

sallustfire avatar Jan 26 '24 06:01 sallustfire

More context on Bazel Slack: https://bazelbuild.slack.com/archives/C04281DTLH0/p1706234301711269

gregmagolan avatar Jan 26 '24 17:01 gregmagolan