-
Notifications
You must be signed in to change notification settings - Fork 455
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
Stack trace line numbers are misaligned when using source-map-support #2372
Comments
See links in issues above in jest and source-map-support. Let me know if I should definitely move this issue to one of those repros. It might be nice to keep it open to track the issue in combination for others experiencing it. |
In general it is not in control of |
Thanks for the quick reply.
Many (most?) typescript users will want to have typescript line numbers in the stack traces. I am not aware of another option for doing that. Are you amenable to the argument that this an issue worth addressing in order to participate in the broader Typescript ecosystem? It's not clear to me why an import would have this effect given what you say, are you able to shed any light on it? |
When we transform The problem of using |
I will not be using ts-jest in production. I import To be clear: the problem arises because I have this import in files under test from my main application. |
Ah so you think it is somehow overriding the metadata you provide? The odd thing is it works fine (line numbers correct) in vanilla node runtime so must be some interaction with jest. I have imported this ticket to this comment: jestjs/jest#10330 (comment) I'll close this here for now. |
What we can try is, allow to disable TypeScript source map via tsconfig. I can investigate about that thing. |
Okay, just for any fellow travellers it would appear than since 12.12.0 (nodejs/node#29564) source-map-support is not required since there is native node support. So unless you transitively depend on it you can safely remove it and still get nice stack traces. That seems to resolve issues with jest/ts-jest. |
Oh I see, so no need any extra investigation then. Thanks for the information ! |
## 🐛 Bug Report
When testing files that use (https://github.com/evanw/node-source-map-support) with:
The line numbers in stack traces displayed via tests run with
ts-jest
are wrong. In particular they point to the source line in the compiled.js
files not the.ts
files despite referencing the.ts
files.I want to use
source-map-support
in my production files to have nice stack traces.To Reproduce
Test a file with
ts-jest
that hasimport 'source-map-support/register';
and throw an error to get a stack trace. See the line numbers are misaligned. Remove the import and see the line numbers are correct.Expected behavior
Line numbers should be correct from
ts-jest
regardless of whethersource-map-support
is imported.Link to repo
Minimal repro here:
https://github.com/silasdavis/ts-jest-repro
Just run
yarn test
(see the README.md for more details).Annotated output:
Debug log:
Find
ts-jest
log here: https://github.com/silasdavis/ts-jest-repro/blob/main/ts-jest.logenvinfo
The text was updated successfully, but these errors were encountered: