Skip to content
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

fix: issue-7715 #23575

Merged
merged 64 commits into from
Sep 9, 2022
Merged

fix: issue-7715 #23575

merged 64 commits into from
Sep 9, 2022

Conversation

rachelruderman
Copy link
Contributor

@rachelruderman rachelruderman commented Aug 26, 2022

User facing changelog

In the terminal, users will now see the source map line and column number in the error stack trace. Fixes #7715

Additional details

Previously, we were finding the stack trace with the source map -- but we weren't doing anything with it 😱 it was appended to the error as error.sourceMappedStack and left to linger, perhaps for debugging purposes.

This PR reassigns the stack property to the value of the source mapped stack and removes the lone property sourceMappedStack.

The purists among us may say,

Hey! Should we really be manipulating the stack property?

To which I will answer,

We were already manipulating the stack property by pointing it to the user's invocation stack via preferredStackAndCodeFrameIndex. This change just ensures the right line number/column is printed in the already-manipulated stack.

Steps to test

  1. Create a dummy test that will fail, i.e. in packages/driver/cypress/e2e/commands/agents.cy.js
Cypress.env('retries', 0)

it.only('should fail', () => {
  expect(false).to.be.true
    // OR
    // cy.get('invalid')
    // 	.should('be.visible')
    // OR
    // cy.origin('http://foobar.com:3500')
})
  1. From the project root, start the runner in one tab with cd packages/runner && yarn watch
  2. From the project root, run your test in another tab with yarn cypress:run --headed --project packages/driver --spec packages/driver/cypress/e2e/commands/agents.cy.js --browser chrome --no-exit
  3. Confirm that the error stack line number/column in the terminal matches the value in VS Code
  4. Confirm that the error stack line number/column in the GUI matches the line number/column in VS Code

For example, all three of these show line 8, column 25: cypress/e2e/commands/agents.cy.js:8:25

  • VS Code:

Screen Shot 2022-08-26 at 1 02 31 PM

  • Terminal:

Screen Shot 2022-08-26 at 1 02 15 PM

  • GUI:

Screen Shot 2022-08-26 at 1 07 39 PM

How has the user experience changed?

Now we see the correct line number/column in the stack trace. Note: you'll notice the stack trace link has changed from http://localhost:3500/__cypress/tests?p=cypress/e2e/commands/agents.cy.js:X:XX to webpack:///./cypress/e2e/commands/agents.cy.js:X:XX, but this has no impact on the user experience since the localhost domain was not relevant to the user's source map in the codebase. In fact, we may be interested in stripping it as we do in the CodeFrame source map line

Before:
Screen Shot 2022-08-26 at 1 18 23 PM

After:
Screen Shot 2022-08-26 at 1 19 15 PM

PR Tasks

  • Have tests been added/updated?
  • Has the original issue (or this PR, if no issue exists) been tagged with a release in ZenHub? (user-facing changes only)
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 26, 2022

Thanks for taking the time to open a PR!

@rachelruderman rachelruderman changed the title fix-issue-7715 fix: issue-7715 Aug 26, 2022
@cypress
Copy link

cypress bot commented Aug 26, 2022



Test summary

40019 0 3346 0Flakiness 2


Run details

Project cypress
Status Passed
Commit c632be7
Started Sep 9, 2022 10:48 AM
Ended Sep 9, 2022 11:03 AM
Duration 14:33 💡
OS Linux Debian - 11.3
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

config_env.cy.ts Flakiness
1 cy.origin- Cypress.config() > serializable > overwrites different values in secondary if one exists in the primary
commands/querying.cy.ts Flakiness
1 cy.origin querying > .get()

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

expect(result.stack).to.equal('replaced stack')
})

it('attaches source mapped stack', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted this test since we're no longer attaching the property sourceMappedStack

@chrisbreiding chrisbreiding marked this pull request as ready for review September 9, 2022 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stack trace log (failed line number) printed in cypress run is different from the stack trace in cypress open
3 participants