Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing a file's access time re-runs tests in watch mode #7124

Closed
kumar303 opened this issue Oct 8, 2018 · 4 comments · Fixed by #7347
Closed

Changing a file's access time re-runs tests in watch mode #7124

kumar303 opened this issue Oct 8, 2018 · 4 comments · Fixed by #7347
Labels

Comments

@kumar303
Copy link

kumar303 commented Oct 8, 2018

🐛 Bug Report

When running jest --watch, changing a file's access time triggers a test re-run.

To Reproduce

Steps to reproduce the behavior:

  • Start jest --watch
  • Change the access time for a file and nothing else. Example: touch -a src/components/SomeComponent.js

Expected behavior

I don't expect Jest to re-run tests when only the access time changes. I would expect it to re-run tests when the modified time changes or new files are added, etc.

Link to repl or repo (highly encouraged)

Please provide either a repl.it demo or a minimal repository on GitHub.

Issues without a reproduction link are likely to stall.

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: macOS Sierra 10.12.6
    CPU: x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
  Binaries:
    Node: 8.11.4 - ~/.nvm/versions/node/v8.11.4/bin/node
    Yarn: 1.9.4 - /usr/local/bin/yarn
    npm: 5.6.0 - ~/.nvm/versions/node/v8.11.4/bin/npm
  npmPackages:
    jest: ^23.1.0 => 23.1.0

The chokidar file watcher always changes access time shortly after a file is modified. I'm not sure why and I'm not sure how to turn it off. Since I use chokidar in a separate shell to run flow as I edit code, this causes my tests to always run twice.

@SimenB
Copy link
Member

SimenB commented Oct 9, 2018

Interesting! @rubennorte thoughts on this?

I don't know if it's part of the metadata we get here: https://github.com/facebook/jest/blob/19ceeb5b31e5ad483d1425bb8cd9a38aa583740b/packages/jest-cli/src/watch.js#L196-L199. It contains `fs.Stats, but I'm not sure if it's possible for us to knwo that's the only thing that changed.

A possible workaround for you is to use https://www.npmjs.com/package/jest-runner-flowtype, not sure if it' feasible or not 🙂

@kumar303
Copy link
Author

kumar303 commented Oct 9, 2018

I've seen apps deal with this kind of thing by comparing access/modified time stamps when getting the change event.

A possible workaround for you is to use https://www.npmjs.com/package/jest-runner-flowtype

Thanks! I didn't know about it. I'll try it.

@rubennorte
Copy link
Contributor

@SimenB we should be able to know when only the access time changed and do nothing in that case.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants