`jest --watch` doesn't pick up changes in source-mapped files
See original GitHub issue🐛 Bug Report
We’re having a TypeScript project that stores intermediate JS files on disk as they’re being used by multiple tools.
(Inline) Source maps in general work fine with Jest, but it doesn’t pick up file changes when I save a .ts
file which then gets transpiled to its respective .js
file.
No tests found related to files changed since last commit.
To Reproduce
Have a TypeScript project that transpiles JS into a folder that is ignored by .gitignore
.
Update a TS file while haven tsc
and jest
both running in watch mode.
Expected behavior
jest
should pick up the file change for the transpiled JS file and figure out that it corresponds to the source TS file which is tracked and modified in Git. It then should run the tests for that file.
Link to repl or repo (highly encouraged)
If you need a reproduction case for this I will happily provide one. But I thought I wait for the initial answer, which might be a definitive “should work” or “work work because X”.
Run npx envinfo --preset jest
Paste the results here:
System:
OS: macOS High Sierra 10.13.4
CPU: x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Binaries:
Node: 8.9.1 - /usr/local/bin/node
Yarn: 1.6.0 - ~/Sources/web/node_modules/.bin/yarn
npm: 5.5.1 - /usr/local/bin/npm
npmPackages:
@types/jest: ^22.2.3 => 22.2.3
jest: ^23.0.1 => 23.0.1
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:10
Top GitHub Comments
@SimenB
I have seen this comment before on a similar issue. I must say I don’t really understand why? All this does is introduce a dependency of some sort of inline transformation step which must be kept maintained and up to date with both jest and the chosen transpiler. At the moment this is a pain because of the incompatibilities between jest and babel 7 (correct me if I’m wrong).
I’d much prefer to simply have one transpilation step, and then just run jest against that output. This is very common procedure on many other platforms where you execute your testrunner against a compiled binary. I can to this now, but the problems are that I have to manually “deconfigure” the
transform
option, as well as missing out on this very helpfulwatch
option because file changes in .gitignored files are simply ignored.I’d be happy to take a stab at this and submit a PR. But this seems to be an intentional feature (?)
I actually came to this page in search of an answer and the discussion made me think about my settings and I realized that I had basically excluded my source code with this setting:
I chanced it to the following and it worked great after that: