-
Notifications
You must be signed in to change notification settings - Fork 490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debugging from jest test is all out of wack with the line numbers #171
Comments
Hmmm, probably there could be some configuration missing for source maps on Jest. That's something we must investigate. |
Could you @dsanders1234 provide some reproduction steps/repo? |
Upon further investigation, it happens when jest configuration "collectCoverage" is set to true |
@dsanders1234 could you describe in detail the issue? Do you have a fix for it? |
When collecting coverage, the code is istrumented, i think. Because of that, the source map generated wouldn't match the actual code. |
I was having the same problem, and I narrowed it down to So I created 2 more tsconfigs.
{
"compilerOptions": {
"moduleResolution": "node",
"target": "es5",
"rootDir": "src",
"sourceMap": true,
"strict": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"suppressImplicitAnyIndexErrors": true,
"baseUrl": ".",
"typeRoots": ["node_modules/@types"]
},
"include": ["src"]
} Then a config for running jest.
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"inlineSourceMap": true,
"inlineSources": true
}
} And finally the config file for rollup to use when building {
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "es2015",
"lib": ["es2015", "es2016", "es2017", "dom"],
"declarationDir": "dist/types",
"outDir": "dist/lib",
"declaration": true,
"allowSyntheticDefaultImports": true
},
"include": ["src"]
} Now I can properly debug tests with VSCode, and linting/building still works. |
@jordond that setup looks nice! Do you mind opening a PR so we can merge the changes with the repo? |
@jordond How do you load I have found this page, it works when running npm run test from command line and runs in Intellij IDEA too, but still no breakpoint because line numbers are still broken :(
|
|
In my case, it seems the problem is only related to I would advocate for removing this setting from |
As code coverage seems to break sourcemaps line numbers, this change moves the coverage option from package.json Jest config to npm script --coverage flag for IDE debugging to work as expected. Close alexjoverm#171
I don't know if this is just a configuration fix (such as to use inline source maps) or what, but it doesn't appear to work out of the box, at least when debugging in IntelliJ. It works when stepping through actual jest code, but not in the code under test.
The text was updated successfully, but these errors were encountered: