-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Source map support #336
Comments
Any way to do this yet? Following suggestions from: http://marmelab.com/blog/2015/06/24/jest-in-practice.html I took out the |
I'm going to assume that this should probably work with babel. I'm going to close this as babel has a I also appreciate contributions to |
I'm using typescript & jest reports the JS line numbers. Is there a workaround? Thx! |
A feature to preserve line numbers in typescript was specifically rejected because they already produce source maps: microsoft/TypeScript#3142 |
@cpojer There is a reason for adding source map support: codecov.io doesn't support coverage reports for files not checked into source control. I tried using remap-istanbul, but it couldn't resolve the original source paths correctly. |
I was finally able to solve this issue. See felipeochoa/jest-sourcemaps for the details. (It's not pretty, but it works!) |
@cpojer I was poking around the refactoring you did in #3376 and #3388 and was excited to see that source maps are cleanly handled when coverage is enabled! Is the plan to allow saving source maps independently of whether coverage is enabled? It seems to me that simply removing the A current limitation of the |
@felipeochoa I have no smart thoughts on this to be honest, so feel free to send a pull request with the changes and with tests and we'll see where can take it. |
So, jest's support for source maps is currently limited to coverage only? If I write a custom preprocessor that extracts inline source maps for TypeScript I get accurate code coverage on my |
I've managed to use Edit: Copy-paste for history: What you need to change in your code for it to work: tkrotoff/react-form-with-constraints@b581782
This blog post: https://medium.com/@novemberborn/code-coverage-with-babel-istanbul-nyc-83b8c2f1093 allowed me to understand. |
@tkrotoff Thanks for your help, you definitely have moved me in the right direction but my istanbul coverage report still shows the incorrect umber of lines. while the actual lines in the file are: Any help would be greatly appreciated. |
@sean-killeen you should use ts-jest, no need for remap-istanbul:
|
I actually started with ts-jest originally and have been getting an error with istanbul-lib-coverage when using it.
that is what spawned this process. update: getting the latest versions of jest and jest-cli have resolved the cli error, however, the initial issue still persists while using ts-jest |
Jest should fully support sourcemaps out of the box now, as long as they are either inline or the transformer returns it (meaning we don't look up external sourcemaps). @sean-killeen could you provide a repro of your issue? |
Is there a conversation somewhere about why jest does not support external source maps/are they considered in the future? Having just transitioned form mocha and with all that's baked in, I somewhat expected this :) The workarounds to get support seem much heavier than other test runners (see #2205 (comment)). |
PR welcome! We support inline sourcemaps, should be possible to support external as well. |
greetings typescript friends i've found two harmonious workflows for jest+typescript+vscode that have worked well for me regarding source maps
if you use inline source maps, try to only do so in a |
@SimenB How does Edit: I'm looking at |
Did you answer your own question? We might want to document how to utilise sourcemaps in Jest, but I'm not sure where to put it. It works out of the box, but custom transforms have to support it explicitly (by returning |
@chase-moskal youp 🍺 inline source map in tsconfig.json compiler options solve the problem !
|
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Inline and external source-map support is very much needed (f.e. when using preprocessors). Is there currently an official way to use source maps so that the line numbers of my errors (the very things that jest revolves around) are meaningful?
The text was updated successfully, but these errors were encountered: