When running jest --watch, changing a file's access time triggers a test re-run.
Steps to reproduce the behavior:
jest --watchtouch -a src/components/SomeComponent.jsI 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.
Please provide either a repl.it demo or a minimal repository on GitHub.
Issues without a reproduction link are likely to stall.
npx envinfo --preset jestPaste 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.
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 馃檪
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.
@SimenB we should be able to know when only the access time changed and do nothing in that case.
Most helpful comment
@SimenB we should be able to know when only the access time changed and do nothing in that case.