Search code examples
javascriptjestjswatchman

jest --watch triggered by temp files


I'm running Jest 26.4.2 on MacOS Catalina using Emacs as my text editor. When the watcher is running, any time Emacs creates a temp file jest will trigger a run. This leads to many runs triggering that tend to miss the actual file save event.

I'm running jest with npx jest --watch

I've tried various jest configs, the one that looked promising, testPathIgnorePatterns, did not help.

Emacs creates temp files by making a symlink with the pattern .#<target file name> that points to a files that ends with 5 digits. I've tried ignoring all these but it didn't help.

jest.config.js:

  watchPathIgnorePatterns: ['/[0-9]{5}/', '/#/'],
  testPathIgnorePatterns: ['/[0-9]{5}/', '/#/'],
  modulePathIgnorePatterns: ['/[0-9]{5}/', '/#/'],


Solution

  • The files created by my editor, Emacs / Spacemacs, are lock files. They are created and removed as soon as files are edited, saved or reverted.

    I could not get jest to ignore them so I configured my Spacemacs TypeScript layer to not create them in TypeScript mode via (typescript :variables create-lockfiles nil).