ts-jest: ts-jest 26.1.2 - "cannot find source file"
🐛 Bug Report
When attempting to run jest tests with VSCode debugger in 25.3.1, I keep getting error “cannot find source file” after making seemingly innocuous changes to the spec or tested file. Reverting the changes to the source file allows the tests to run. Reverting to 25.2.1 fixes the error.
System:
OS: OSX 10.15.4
Npm packages:
jest: 25.2.7
ts-jest: 25.3.1
typescript: 3.8.3
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 8
- Comments: 47
Commits related to this issue
- Revert "Upgrade Jest to fix security warnings" This reverts commit aac26e2d0d23115d96be94a38ca366105762008d. https://github.com/kulshekhar/ts-jest/issues/1506 — committed to bash-lsp/bash-language-server by skovhus 4 years ago
- Update package to temporarily fix ts-jest bug jest --clearCache currently has to be run before running jest to prevent tests from failing. See https://github.com/kulshekhar/ts-jest/issues/1506 — committed to PhilipVigus/chitter-typescript-backend by PhilipVigus 4 years ago
- fix(compiler): check if test file exists before doing type check (#1827) Close #1506 — committed to kulshekhar/ts-jest by ahnpnl 4 years ago
- Add option to add --build-arg's to docker Add test for build args Update jest and ts-jest to resolve an issue where the test file is missing: https://github.com/kulshekhar/ts-jest/issues/1506 — committed to philips-labs/docker-action by bas-l 3 years ago
- Feature/add build args (#4) * Add option to add --build-arg's to docker Add test for build args Update jest and ts-jest to resolve an issue where the test file is missing: https://github.com/kulshe... — committed to philips-labs/docker-action by bas-l 3 years ago
yes, running
jest --clearCacheallows the test to pass, but then changing the value again (e.g. toqum = 'quo') causes it to immediately fail again👋🏽just hit this same issue in VSCode, I can workaround by running
jest --clearCache && jest, so it’s not a blocker. I was just wondering about the ETA of a new releaseThis bug is still present in the latest version, at least with Next.js serverless functions.
I also use the latest version and had this problem, only in watch mode, the normal tests passed perfectly. After clearing the cache it was fixed.
v26.1.4 is out, I will close this issue
Happening again on OSX ^26.1.0
Downgrading to ^25.5.1 solves the issue
I have the same issue with all my typescript projects since the update to
25.3.1. After a successful test run, as soon as I change anything in a source file and run the test again, I get the same error. Reverting the change allows the test to complete.At the moment, all I can do is keep running
jest --clearCacheevery time I change something, or roll back to a previous version of ts-jest.I set up an example repo that mimics my project setup if it’s of any use: https://github.com/rav2040/ts-jest-error-could-not-find-source-file
I included a GitHub CI test workflow in the repo. If you look at the workflow logs you’ll see the test managed to complete even after I changed the value of ‘foo’ in the source file.
However, when I do the same thing on my own machine I get the following:
I also tried cloning the repo to a Digital Ocean droplet and running it there, and I still got the same error.
Upgrading to the latest (^25.5.1 at the time of writing) solved the issue for me. Thanks!
@mordigann228 you can: either use 25.2.1 or use clear cache or wait for the next release 😃
thank you guys for the information, will look into it asap. Stay tune 😃
Updated: would you guys please test the fix with this tgz file https://drive.google.com/open?id=1QRnkDOIy7BXQdSjcybzveBkmE1uCU8h5
Still present, cleaning cache doesn’t solve, google drive links in this thread are useless as they can be deleted.
@ahnpnl using this version right now, so far so good. Thank you for your support
Hi @magwas, @x87, @dwjohnston, @lmanerich, @impulse
v26.1.4-alpha.0 is out with the fix. Would you guys please test it by install ts-jest@next ?
If it works, I will publish a new release and close this issue.
Let me know
do you use watch mode or non-watch mode ? Hmm I tried renaming but I don’t see the issue either. I might know how to fix it but need reproduce steps that can verify the fix.
I think the steps are:
you need to clear jest cache, not npm cache
@ahnpnl updating to v26.1.3 solved the issue. Was with v26.1.2 and “jest:26.1.0”. Thanks
thank you guys, will open a PR for it.
Logs:
Working on a repro