Issue
The debugger doesn't stop at correct statements in VSCode in source files
Expected behavior
The debugger should stop at correct statements in VSCode for source files
Link to a minimal repo that reproduces this issue
ts-jest-node8-debugger-repro/jest-22-test

Optional (but highly recommended) - Configure Travis (or your favorite system) with the minimal repo
Done
Similar issue was discussed in #309
This issue is not reproducible if I remove "collectCoverage": true from Jest Config (code)
Confirmed that issue is reproducible with latest version [email protected], and updated repro repo and issue description
Same problem in Webstorm
I removed collectCoverage from jest.json and added --coverage in Jest CLI to avoid this bug
Thanks but no luck in my environment (Create-React-App-Typescript):
// package.json
// ...
"scripts": {
"test": "jest --verbose --notify",
"test:watch": "jest --watch --notify",
"test:debug": "jest --debug",
"test:update": "jest -u",
"coverage": "jest --coverage --silent"
},
"jest": {
"setupFiles": [
"<rootDir>/config/test-shim.js",
"<rootDir>/config/test-setup.js"
],
"globals": {
"ts-jest": {
"skipBabel": true
}
},
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"transform": {
"^.+\\.(ts|tsx)$": "<rootDir>/config/test-preprocessor.js",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/config/assetsTransformer.js",
"\\.(css|less)$": "<rootDir>/config/assetsTransformer.js"
},
"roots": [
"src"
],
"testMatch": [
"**/test/*.(test).(ts|tsx|js)"
],
"collectCoverageFrom": [
"src/orm/**/*.{js,tsx,ts}",
"!src/index.tsx",
"!src/App.tsx",
"!src/orm/test/models/**"
]
}
// ...
I've taken a look at the linked repo and can confirm noticing this issue. I tried debugging a bit but couldn't figure out the root cause.
Maybe the root cause has more to do with jest itself than with ts-jest
The fix for #485 (which seems to be in jest) might fix this but that's just a hunch and not based on any evidence
Indeed, it seems to be a jest issue
https://github.com/facebook/jest/issues/5925
@YagoLopez thanks for testing that out!
Is it https://github.com/facebook/jest/issues/5739? facebook/jest#5925 is for thrown errors, not source stepping
@SimenB that's correct, thanks for the clarification
@YagoLopez did you find a workaround?
I have exactly this problem :( but with IntelliJ

Thanks
Running the test like
node --inspect-brk=0.0.0.0:5858 ../../node_modules/.bin/jest --no-cache --watch --runInBand
with the following config
module.exports = {
transform: {
"^.+\\.(t|j)sx?$": "ts-jest"
},
testRegex: "(/tests/.*.(test|spec)).(jsx?|tsx?)$",
testPathIgnorePatterns: ["/lib/", "/node_modules/"],
moduleFileExtensions: [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
verbose: true,
globals: {
"ts-jest": {
disableSourceMapSupport: true
}
}
}
Sorry but not. Are you in the latest versions of IntelliJ with all dependencies up to date (jest, ts-jest, etc)? May be that could help but I cannot confirm it.
IntelliJ IDEA 2018.1.5 (Ultimate Edition)
Build #IU-181.5281.24, built on June 13, 2018
JRE: 1.8.0_152-release-1136-b39 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.13.5
"jest": "23.2.0",
"ts-jest": "22.4.6",
Yeah yarn outdated spits nothing so I should be up to date.
Thanks for answering.
Take a look at this:
https://github.com/kulshekhar/ts-jest/issues/150#issuecomment-291209244
And a little of more info here:
http://jestjs.io/docs/en/troubleshooting.html
If you have luck, please report it here.
Having same issue here, I thought it was related to multiline import statement and/or multiline function (...) header that is why my minimal repo has such weird code, but after putting everything in one line I have still the same issue. @YagoLopez I've also tried setting inlineSourceMap without success (thought it should be the default now - as I am using latest jest and ts-jest).
Notice that running yarn test the throw is shown at correct line number:

But if you try to debug in vscode with debugger statement (putting a breakpoint will stop nowhere), it's totally at the wrong line:

Here is the minimal repo: https://github.com/huafu/issue-ts-jest-wrong-line
FYI my jest cache has been cleared, and I'm using an up to date vscode on latest macOS
...I've created a new issue #606, because it sounds like a different one from @trivikr – he is using version 22 of jest and ts-jest, while I'm using 23, and when I downgrade ts-jest to version @<23, vscode goes to the correct line, where debugger statement actually is.
tested as explained by @trivikr, #626 will fix this (tho you MUST remove the babelrc: false from jest config in package.json. (tested with and without coverage)
fixed in 23.1.2
Reproducible on ts-jest 24.0.2 and jest 24.8.0. Removing collectCoverage: true from jest.config.js helped
Here is new issue created #917 .
Most helpful comment
Similar issue was discussed in #309
This issue is not reproducible if I remove
"collectCoverage": truefrom Jest Config (code)