Each test target - unit-test, int-test, e2e-test - should be invalidated whenever the tested code changes, or the tests themselves change. Currently, the cache isn't being invalidated when fixtures change - i.e. files which aren't imported in code, but are read from file system with node:fs module (usually copied to a temporary test folder in beforeEach/beforeAll).
Because of this, we run the risk of merging broken tests, which will be hard to track down.
Steps to reproduce
- Run
npx nx int-test plugin-eslint. Tests will pass and Nx will save cache.
- Change any file under
packages/plugin-eslint/mocks/fixtures in a way that should break some test (e.g. delete nx-monorepo/nx.json).
- Re-run
npx nx int-test plugin-eslint. Tests will pass instantly, Nx logs that cache was used.
- Run
npx nx int-test plugin-eslint --skipNxCache. Observe that tests fail.
This is repeatable for any other type of test that relies on file system - i.e. some integration tests, most E2E tests.
Proposed solution
See discussion, mainly this comment
Acceptance criteria
Each test target -
unit-test,int-test,e2e-test- should be invalidated whenever the tested code changes, or the tests themselves change. Currently, the cache isn't being invalidated when fixtures change - i.e. files which aren'timported in code, but are read from file system withnode:fsmodule (usually copied to a temporary test folder inbeforeEach/beforeAll).Because of this, we run the risk of merging broken tests, which will be hard to track down.
Steps to reproduce
npx nx int-test plugin-eslint. Tests will pass and Nx will save cache.packages/plugin-eslint/mocks/fixturesin a way that should break some test (e.g. deletenx-monorepo/nx.json).npx nx int-test plugin-eslint. Tests will pass instantly, Nx logs that cache was used.npx nx int-test plugin-eslint --skipNxCache. Observe that tests fail.This is repeatable for any other type of test that relies on file system - i.e. some integration tests, most E2E tests.
Proposed solution
See discussion, mainly this comment
Acceptance criteria
{projectRoot}should invalidate test targets in Nx cache.