TypeScript and Jest - debugger stops only on breakpoints in tests, never in source files

Hi,

I am using TypeScript and Jest.

I have no issue to get debugger stop on proper line in the test file, but I cannot get it stopped in the source files.

 

This is my `jest.config.json`:

```

module.exports = {
collectCoverage: true,
collectCoverageFrom: ['src/**/*.ts'],
globals: {
'ts-jest': {
tsConfig: {
sourceMap: true,
inlineSourceMap: true
}
},
},
preset: 'ts-jest',
testEnvironment: 'node',
};

```

Any help?

6 comments
Comment actions Permalink

Try changing collectCoverage to false - does it help?

"collectCoverage": false,

If the source file is instrumented for coverage, the generated code can't be mapped to source; it's a well known limitation

5
Comment actions Permalink

Elena Pogorelova God bless you for this. I'd been struggling to get this work for days. Thanks.

0
Comment actions Permalink

If you want to keep that option in your config file, you can turn that off in the run configuration for Jest as well by adding the Jest option `--coverage=false`, ideally in the run configuration template.

2
Comment actions Permalink

I'm also trying to debug a Jest test in a complex monorepo. I've disabled coverage collection in both ways explained above, but I still can't get the debugger to stop on any line. Instead, WebStorm opens index.js (instead of staying in index.ts), and the debugged goes into a limbo state, when nothing seems to be going on.

This problem only occurred in one file. Another Jest TS from another project would debug fine.

I managed to get the debugger working on the problematic file as well, by deleting workspace.xml.

WebStorm 2019.3.3
Build #WS-193.6494.34, built on February 11, 2020
Runtime version: 11.0.5+10-b520.38 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.3.0-28-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 935M
Cores: 8
Registry:
Non-Bundled Plugins: com.intellij.lang.jsgraphql

0
Comment actions Permalink

Please share a sample project the issue can be reproduced with

0
Comment actions Permalink

If only it were that easy :( I'm working on a complex project with proprietary code and the issue happens with only one very large file. It happened again after I added a few lines of TypeScript (a type definition) near the top of the file. WebStorm keeps opening the .js file every minute or so, even though I closed the file switched to a different task (but the debugger was still apparently "running" - I hadn't clicked the square button to stop it).

Invalidating caches and restarting didn't help, but removing the XDebuggerManager tag in workspace.xml worked.

0

Please sign in to leave a comment.