microsoft/rushstack

[heft-jest] In watch mode, changedFiles should only remove files that match before/after the run

dmichon-msft opened this issue · 1 comments

Summary

In watch mode, changed file state is cleared more aggressively than it should be, so sometimes changes don't trigger test runs.

Repro steps

Run heft test-watch in a project with a long-running test.
Change a file.
While the test is running, change it again.
Observe that the latter change doesn't trigger a new run.

Details

After a successful run, heft-jest-plugin currently clears the list of changed files:

// If we ran tests and they succeeded, consider the files to no longer be changed.
// This might be overly-permissive, but there isn't a great way to identify if the changes
// are no longer relevant, unfortunately.
this._changedFiles.clear();

It should instead snapshot the current change state prior to the run, then remove files for which the current tracked version matches the version the run "used" (quoted because the plugin doesn't quite have access to the actual runtime version of the file, but a timestamp can be applied when the change notification fires).

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@rushstack/heft-jest-plugin version? 0.11.23
Operating system? Linux
Would you consider contributing a PR? Yes
Node.js version (node -v)? v18.19.1

I've noticed something similar with TypeScript, where errors at some point stop getting reported.