Skip to content

fix: ensure that code frames within cy.origin point to the right line of the code#32597

Merged
ryanthemanuel merged 9 commits into
developfrom
ryanm/fix/origin-code-frames
Sep 30, 2025
Merged

fix: ensure that code frames within cy.origin point to the right line of the code#32597
ryanthemanuel merged 9 commits into
developfrom
ryanm/fix/origin-code-frames

Conversation

@ryanthemanuel
Copy link
Copy Markdown
Collaborator

@ryanthemanuel ryanthemanuel commented Sep 29, 2025

Additional details

This PR fixes code frames within cy.origin. It does this by adding a line offset to the user invocation stack for commands within cy.origin based on the stack trace of the evaled statement that is executed within cy.origin.

Steps to test

How has the user experience changed?

PR Tasks


Note

Fixes cy.origin error code frames/stack traces to reference the correct spec line/column by merging cross-origin invocation stacks and propagating them through error handling.

  • Driver (cy.origin error handling)
    • Propagate cross-origin user invocation stacks: send crossOriginUserInvocationStack from packages/driver/src/cross-origin/origin_fn.ts and attach to err in packages/driver/src/cy/commands/origin/index.ts.
    • Include originUserInvocationStack in state sent to secondary origin; merge into local stacks when capturing command stacks in packages/driver/src/cypress/cy.ts and packages/driver/src/cypress/chainer.ts.
  • Stack utilities
    • Filter cross-origin frames in normalizedUserInvocationStack and add mergeCrossOriginUserInvocationStack to adjust top frame line/column across origins (packages/driver/src/cypress/stack_utils.ts).
  • Tests
    • Add/adjust unit tests for stack merging and filtering; update system tests to verify correct spec file positions, add assertion case, and support skipTitleValidation.
  • Changelog
    • Note bugfix: code frames in cy.origin now show correct spec line/column.

Written by Cursor Bugbot for commit 0c39017. This will update automatically on new commits. Configure here.

Comment thread packages/driver/src/cypress/cy.ts Outdated
Comment thread packages/driver/src/cypress/cy.ts Outdated
Comment thread system-tests/projects/e2e/cypress/e2e/cy_origin_error.cy.ts
@ryanthemanuel ryanthemanuel self-assigned this Sep 29, 2025
@cypress
Copy link
Copy Markdown

cypress Bot commented Sep 30, 2025

cypress    Run #65939

Run Properties:  status check passed Passed #65939  •  git commit 0c390174bd: clean up
Project cypress
Branch Review ryanm/fix/origin-code-frames
Run status status check passed Passed #65939
Run duration 19m 53s
Commit git commit 0c390174bd: clean up
Committer Ryan Manuel
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 11
Tests that did not run due to a developer annotating a test with .skip  Pending 1102
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 26666
View all changes introduced in this branch ↗︎
UI Coverage  44.73%
  Untested elements 189  
  Tested elements 157  
Accessibility  97.71%
  Failed rules  4 critical   8 serious   2 moderate   2 minor
  Failed elements 110  

@ryanthemanuel ryanthemanuel merged commit 96bd60d into develop Sep 30, 2025
90 of 92 checks passed
@ryanthemanuel ryanthemanuel deleted the ryanm/fix/origin-code-frames branch September 30, 2025 19:46
Copy link
Copy Markdown
Collaborator

@AtofStryker AtofStryker left a comment

Choose a reason for hiding this comment

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

just for changelog consistency but we can update this on release day

Comment thread cli/CHANGELOG.md
**Bugfixes:**

- Fixed a regression introduced in [`15.0.0`](https://docs.cypress.io/guides/references/changelog#15-0-0) where `dbus` connection error messages appear in docker containers when launching Cypress. Fixes [#32290](https://github.com/cypress-io/cypress/issues/32290).
- Fixed code frames in `cy.origin` so that failed commands will show the correct line/column within the corresponding spec file. Addressed in [#32597](https://github.com/cypress-io/cypress/pull/32597).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Fixed code frames in `cy.origin` so that failed commands will show the correct line/column within the corresponding spec file. Addressed in [#32597](https://github.com/cypress-io/cypress/pull/32597).
- Fixed code frames in [`cy.origin()`](http://on.cypress.io/api/origin) so that failed commands will show the correct line/column within the corresponding spec file. Addressed in [#32597](https://github.com/cypress-io/cypress/pull/32597).

cacieprins pushed a commit that referenced this pull request Oct 1, 2025
… of the code (#32597)

* fix: ensure that code frames within cy.origin point to the right line of the code

* additional tests

* additional tests

* changelog

* Apply suggestions from code review

* Update system-tests/projects/e2e/cypress/e2e/cy_origin_error.cy.ts

* fix tests

* fix tests

* clean up
@cypress-bot
Copy link
Copy Markdown
Contributor

cypress-bot Bot commented Oct 7, 2025

Released in 15.4.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v15.4.0, please open a new issue.

@cypress-bot cypress-bot Bot locked as resolved and limited conversation to collaborators Oct 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants