-
-
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
Jest giving wrong line number for error #5446
Comments
I also copied my code to the react official example, and it had the same problem |
@zwhitchcox that repo is empty 😬 |
Sorry! Just pushed! |
Does this repro without |
No, it wasn't working, and I added that thinking it might work |
@zwhitchcox it would be helpful if you could remove everything you can from the test repo @jwbay I had the same thought, but I tested and it's not related to |
I created the absolute minimum repo: https://github.com/rickhanlonii/jest-issue-5446 See the comment here for an interesting finding: |
Thanks, sorry, I would've done that, but I'm not home right now. And yeah, I think it's probably babel, but Facebook de facto owns anything related to the internet anyway, right?? |
Vaguely related to #5449. If I apply the same changes here as I propose in there, this is the error: |
Hi. I'm using Node 8.9.4 with
The test output is:
So the error should be at line 32, but Jest says it is at line 41, a difference of 9. For babel, I'm using:
|
Can you create a repro showing this? |
@rickhanlonii your example is fixed after #5177. The OP is still wrong, though... |
@zwhitchcox you're using a transformer called - require('source-map-support').install() I've just verified it works as expected (from master branch). |
@thymikee I am running 22.4.2 and it still requires |
That's odd. Do you have a reproduction we can pull down and take a look at? |
Unfortunately, I do not have one yet. However, it appears it may be isolated to typescript files, which source-map-support seems to fix from a jest reporting perspective. I am also having issues with code stepping inside the file to be tested. The source maps are way off but fine on the actual TS test file. I'll probably take this over to ts-jest repo if I cannot get this resolved. Thanks. |
Are you using ts-jest? If so, can you try downgrading (or upgrading if you're not on latest)? Wondering if it's related to kulshekhar/ts-jest#449 |
So, there is two issues: @SimenB Source stepping typescript breaks in jest when collectCoverage is set to true. Regardless of ts-jest version. Currently only tested with jest 22.4.2. Removing the collectCoverage line from package.json results in proper source stepping. It worked before mapCoverage was deprecated. |
Does it help to apply this diff? #5692 |
I cloned the latest master which includes #5692 and yarn linked it. It still has the same issue when collectCoverage=true. For those following along, I created an incorrect line error reporting bug for ts-jest here: |
... since we're diverging with the ts-jest thread, I'd like to draw attention back to @rickhanlonii's finding in this repro. I've found the same thing in my own project, where changing I think this issue is not yet resolved and hope it can be reopened. 🙏 |
I worked with the OP repo as well, and have confirmed that changing to Before: After: Here's the OP repo updated with |
I'm using ts-jest and my error lines are completely wrong. Is this still an issue? |
FWIW my version of this appears to have been caused by babel-plugin-source-map-support. Removing it from my plugins fixed jest error lines. |
I am having the same problem. I am using the following packages:
I am not sure what to do to fix the problem since I don't use any sourcemaps. |
FUTURE PEOPLE: If you have |
same issue +1 |
Still getting the same issue. Using |
I have this issue on my project when using both |
For those who are having this issue in 2020... Running jest through And I've learned that jest has coverage collection built in, so you can uninstall |
My project do not have |
In my project, I found that the problem is caused by an npm module (dynamoose) which imports So I replaced it with a mock in
then the problem is fixed. |
I am having this issue too in Jest 26 (since last July) with Angular 9/10/11. I've detailed the issue with a minimal repository here |
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. |
Do you want to request a feature or report a bug?
Bug report
What is the current behavior?
It gives the line number a few lines above where the error actually is. The error should be on line 7, where Object.assign is run, but it is giving the error on line 10.
Sourcemaps appear to be working, but this particular instance, they didn't for some reason.
I made a repo https://github.com/zwhitchcox/jest-bug, you just have to git clone, yarn install and yarn test
What is the expected behavior?
To give the correct line number
Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.
Node: v8.4.0
Jest: 22.1.4
OS: GalliumOS (basically Ubuntu 14.04)
yarn: 1.1.0
The text was updated successfully, but these errors were encountered: