cypress
cypress copied to clipboard
Stacktrace for errors in Cypress command log does not match the file when using Typescript
Current behavior
- Execute cypress run,
- Test fails
- click the line in the backtrace (in PHPStorm)
- code does ot match
Line numbers of stack trace don't match the code in cypress 12.8
Basically the same like in
https://github.com/cypress-io/cypress/issues/7715
Desired behavior
The line numbers match the code
Test code to reproduce
Cypress Version
12.8.0
Node version
16.17.0
Operating System
Ubuntu 22.04
Debug Logs
No response
Other
No response
@amenk Thanks for the reporting the issue. Can you please try on the latest version of Cypress to see if you can still reproduce this? Also, can you please provide a reproducible example of the issue you're encountering. Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide.
@warrensplayer Thanks, we tried 12.11.0 as well - same issue - on different machines. Will try to cook up a smaller example.
@amenk Would you like to correct the typo in your issue title? "ot" => "not"
Thanks @amenk, https://github.com/cypress-io/cypress-test-tiny might be useful to make the repro. It seems like there could be many variables at play. A quick test for me showed normal behavior when clicking through from a failing test - got to the correct line and character in the file in VS Code.
okay, thanks. By the way: In our case even the built-in code view on the left sometimes did not match the error.
Will try to provide better info soon.
I observe something else: Our code does not have ";" at the end, the cypress code has - so there is some transpilling happening there, I guess? Is this maybe messing up the line numbers?
Yeah this is interesting, happy to take a closer look if we can reproduce - otherwise it will be very difficult to track down and verify that we have fixed something.
Hello,
I'm facing the same bug, but I'm using Typescript. I made a repro based on the tiny cypress project.
https://github.com/Breek/cypress-test-tiny
2 commits:
- add Typescript
- create failing test to show the bug
It goes to line 25, but shoud go to 32 for the failing test.
Happy to help, Cheers Jérémy
Screenshot to help.
Cool, we use a mix of TS and JS files by the way.
Thanks for the repro @jchatard and the screenshot :), I confirmed with the repro provided that simply changing the extension in the Cypress test from .cy.ts
to .cy.js
"fixes" this.
Looks like a longstanding bug, I confirmed it all the way back in 9.7.0. Routing to the team to check it out further.
Actually worth noting that typescript was not a part of your screenshots @amenk, I see a js file there. Can you confirm does js
vs ts
for the test make any difference to you?
@marktnoonan Good point.
I have a single .ts
file (besides cypress.config.ts
) in the project (support/index.d.ts
) which was not part of the stacktrace. Still, renaming this file to index.d.js
does not fix the line numbers.
I also have a problem with the stack trace. The printed line numbers do not match the line numbers in the source files:
Test error:
commands.ts code snippet:
Note that the stack trace shows the compiled javascript, for example var productPriceFormatted = productPrice + '.00'
instead of const productPriceFormatted: string = productPrice + '.00';
Our project uses pure TypeScript for Cypress, e.g.:
-
cypress.config.ts
-
support/commands.ts
-
support/e2e.ts
-
tests/10_login.cy.ts
And so on. I tried many different settings in tsconfig.json to get the source maps working correctly, but to no avail.
I use: Cypress 13.3.2 Node 16.20.0 Ubuntu 23.04
Are there any plans to fix this, please?
Same problem