-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix: normalize test body invocationDetails from stack traces
#32699
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
base: develop
Are you sure you want to change the base?
Conversation
… invocationDetails
cypress
|
||||||||||||||||||||||||||||
| Project |
cypress
|
| Branch Review |
astone123/fix-itgrep-trace
|
| Run status |
|
| Run duration | 17m 08s |
| Commit |
|
| Committer | Adam Stone-Lord |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
5
|
|
|
131
|
|
|
0
|
|
|
5535
|
| View all changes introduced in this branch ↗︎ | |
|
@mschile @mabela416 |
mabela416
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it locally and it works
| } | ||
| } | ||
|
|
||
| // if the stack includes the 'itGrep' function, remove any lines that include it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely good to reference what itGrep is and where it is coming from (same with above) https://github.com/cypress-io/cypress/blob/develop/npm/grep/src/register.ts#L77. people who aren't familiar with @cypress/grep will struggle to understand what this means.
The other concern I have is that there could be something legitimate in the stack that has itGrep in it that we want to capture but are omitting it here. Or is this only considered when trying to calculate the row/column in the spec file where the error occurred?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment there. I'm pretty sure this function is specifically used to identify where the test was executed from, so this shouldn't affect anything else. If it does, it'll be limited to use of the grep plugin
|
@mschile I updated this so that it works for tests with .only as well as tests that are nested in suite definitions |
itGrep lines from stack trace when determining invocationDetailsinvocationDetails from stack traces
| ) | ||
| ) { | ||
| lines.shift() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Fix Chrome stack normalization for Context.eval lines
The Chrome stack normalization logic only checks for lines starting with at eval or at Suite.eval, but test invocation lines can also start with at Context.eval. This causes the function to incorrectly remove valid test invocation lines, potentially returning an empty stack or the wrong line. The condition should also check for at Context.eval to handle all test body invocation patterns.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be missing something, but from my testing, even if we use context, the stack still contains Suite.eval. So I think this is fine
| const splitAtAt = line.split('@') | ||
|
|
||
| // firefox stacks traces look like: | ||
| // functionName@https://aicotravel.com/__cypress/tests?p=cypress/support/e2e.js:444:14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use a different url besides aicotravel in the docs here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops - meant to change that. Will update that to something else
This PR closes https://github.com/cypress-io/cypress-services/issues/11991
Additional details
There are a few cases where we don't correctly derive the test body invocation details from the stack trace. This PR fixes those scenarios by looking for
at evalorat Suite.evalin Chrome stack traces, and lines with anonymous functions in Firefox stack traces. This will allow Cypress Studio and "Open in IDE" features to work in more cases than they did before.One of these situations is when
ithas been re-written asitGrepwhich happens in the@cypress/grepand@bahmutov/cy-grepplugins. This allows us to determine the correct invocation details for the test.Steps to test
I tested this with the
@bahmutov/cy-greppackage. Install the package and register it in your support file in accordance with the documentation. Open Cypress Studio by clicking the "edit in studio" button next to a test. Verify that the test content is loaded correctly and you can edit and save the test as expected.How has the user experience changed?
Users of
@bahmutov/cy-greppackage can now use Cypress studio as intendedPR Tasks
cypress-documentation?type definitions?Note
Normalize test-body invocationDetails by trimming wrapper frames (Chrome/Firefox) and update e2e/unit tests so Open in IDE targets correct file/line/column.
invocationDetailsfrom stack traces by addingstackWithWrappingLinesRemovedand updating$stackUtils.getInvocationDetails(specWindow, projectRoot, 'test-body').mocha.ts, pass'test-body'when populatingtest.invocationDetailsinSuite.prototype.addTest.packages/driver/test/unit/cypress/stack_utils.spec.ts):Cypress.isBrowserand adjust project root handling.packages/app/cypress/e2e/runner/reporter.hooks.cy.ts):.only, and wrappedit.system-tests/.../hooks/wrapped-it.cy.jsto exercise wrappeditscenario.Written by Cursor Bugbot for commit 96a9a10. This will update automatically on new commits. Configure here.