Skip to content

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

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      High priority

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions