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

Cypress error outputs dead link #6096

Closed
1 of 6 tasks
crfrolik opened this issue Jan 30, 2025 · 6 comments
Closed
1 of 6 tasks

Cypress error outputs dead link #6096

crfrolik opened this issue Jan 30, 2025 · 6 comments

Comments

@crfrolik
Copy link

crfrolik commented Jan 30, 2025

Description

When a command fails with a cy.origin error (see description), it outputs a URL that is a dead link

URL of Issue(s)

https://on.cypress.io/cy-visit-succeeded-but-commands-fail%1B[0m%1B[90m

Steps to replicate

2025-01-30 11:16:39         CypressError: The command was expected to run against origin `<my-url-1>`/ but the application is at origin `<my-url-2>`/.
2025-01-30 11:16:39    
2025-01-30 11:16:39    This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.
2025-01-30 11:16:39    
2025-01-30 11:16:39    Using `cy.origin()` to wrap the commands run on `<my-url-2>`/ will likely fix this issue.
2025-01-30 11:16:39    
2025-01-30 11:16:39    `cy.origin('<my-url-2>', () => {`
2025-01-30 11:16:39    `  <commands targeting my-url-2/ go here>`
2025-01-30 11:16:39    `})`
2025-01-30 11:16:39    
2025-01-30 11:16:39    This error occurred while creating the session. Because the session setup failed, we failed the test.
2025-01-30 11:16:39    
2025-01-30 11:16:39    [https://on.cypress.io/cy-visit-succeeded-but-commands-fail](https://on.cypress.io/cy-visit-succeeded-but-commands-fail%1B[0m%1B[90m)
2025-01-30 11:16:39          at cy.session.cacheAcrossSpecs.cacheAcrossSpecs [as setup] (webpack:///../cpf-page-objects/signin.po.ts:102:0)
2025-01-30 11:16:39          at Context.<anonymous> (https://redacted/__cypress/runner/cypress_runner.js:132889:38)
2025-01-30 11:16:39          at getRet (https://redacted/__cypress/runner/cypress_runner.js:118338:20)
2025-01-30 11:16:39          at tryCatcher (https://redacted/__cypress/runner/cypress_runner.js:1777:23)
2025-01-30 11:16:39          at Promise.attempt.Promise.try (https://redacted/__cypress/runner/cypress_runner.js:4285:29)
2025-01-30 11:16:39          at Context.thenFn (https://redacted/__cypress/runner/cypress_runner.js:118349:66)
2025-01-30 11:16:39          at Context.then (https://redacted/__cypress/runner/cypress_runner.js:118600:21)
2025-01-30 11:16:39          at wrapped (https://redacted/__cypress/runner/cypress_runner.js:137883:19)
2025-01-30 11:16:39      From Your Spec Code:
2025-01-30 11:16:39          at cy.session.cacheAcrossSpecs.cacheAcrossSpecs [as setup] (webpack:///../cpf-page-objects/signin.po.ts:102:0)
2025-01-30 11:16:39          at Context.<anonymous> (https://redacted/__cypress/runner/cypress_runner.js:132889:38)
2025-01-30 11:16:39          at getRet (https://redacted/__cypress/runner/cypress_runner.js:118338:20)
2025-01-30 11:16:39          at tryCatcher (https://redacted/__cypress/runner/cypress_runner.js:1777:23)
2025-01-30 11:16:39          at Promise.attempt.Promise.try (https://redacted/__cypress/runner/cypress_runner.js:4285:29)
2025-01-30 11:16:39          at Context.thenFn (https://redacted/__cypress/runner/cypress_runner.js:118349:66)
2025-01-30 11:16:39          at Context.then (https://redacted/__cypress/runner/cypress_runner.js:118600:21)
2025-01-30 11:16:39          at wrapped (https://redacted/__cypress/runner/cypress_runner.js:137883:19)

The link it gives results in a 404.

The hyperlink seems to have some weird escape sequences:

https://on.cypress.io/cy-visit-succeeded-but-commands-fail%1B[0m%1B[90m

Browser

No response

Device

  • PC
  • Mac
  • iPhone
  • iPad
  • Android Phone
  • Android Tablet

Additional Information

No response

@MikeMcC399
Copy link
Contributor

@crfrolik

%1B[0m%1B[90m are text formatting escape sequences, so I don't think this is a documentation issue, since the URL

https://on.cypress.io/cy-visit-succeeded-but-commands-fail

works correctly.

Where are you viewing the logs? How are you running Cypress? Is this perhaps GitHub Actions?

@crfrolik
Copy link
Author

I am viewing it from Jenkins logs - I'm not actually sure how those formatting sequences got there, though.

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Jan 31, 2025

@crfrolik

Which version of Cypress are you using? The formatting sequences are to change the color for warnings. For example in Cypress 14.0.1 if you execute the following test in the Cypress Runner (npx cypress open):

describe('testing cy.origin()', () => {
  it('navigates to two different superdomains', () => {
    cy.visit('https://github.com/cypress-io/cypress')
    cy.visit('https://example.cypress.io') // visit a different superdomain
    cy.get('h1').should('contain', 'Kitchen Sink') // fails
  })
})

the output is

Image

Running the same test in a terminal window (npx cypress run) shows the log different, but also using colors:

Image

You may be able to suppress the color changes in Jenkins logs, for instance, if you are running in Linux, with the TERM environment variable.

@crfrolik
Copy link
Author

I am using 14.0.1.

If you think this is not an issue with Cypress, and is related to my environment, feel free to close this issue as such.

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Jan 31, 2025

@crfrolik

I can reproduce the issue on GitHub Actions viewing raw logs, where these color formatting escape sequences appear in a lot of places:

[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m�[90m─�[39m
2025-01-31T15:37:44.1729937Z                                                                                                     
2025-01-31T15:37:44.1730433Z   Running:  �[90mspec.cy.js�[39m                                                                      �[90m(1 of 1)�[39m
2025-01-31T15:37:46.1031080Z 
2025-01-31T15:37:46.1034442Z �[0m�[0m
2025-01-31T15:37:46.1073356Z �[0m  testing cy.origin()�[0m
2025-01-31T15:37:55.1100893Z   �[31m  1) navigates to two different superdomains�[0m
2025-01-31T15:37:55.1183433Z 
2025-01-31T15:37:55.1344270Z 
2025-01-31T15:37:55.1346648Z �[92m �[0m�[32m 0 passing�[0m�[90m (9s)�[0m
2025-01-31T15:37:55.1347527Z �[31m  1 failing�[0m
2025-01-31T15:37:55.1348180Z 
2025-01-31T15:37:55.1348855Z �[0m  1) testing cy.origin()
2025-01-31T15:37:55.1349353Z        navigates to two different superdomains:
2025-01-31T15:37:55.1351061Z �[0m�[31m     CypressError: Timed out retrying after 4000ms: The command was expected to run against origin `https://github.com` but the application is at origin `https://example.cypress.io`.
2025-01-31T15:37:55.1352927Z 
2025-01-31T15:37:55.1353494Z This commonly happens when you have either not navigated to the expected origin or have navigated away unexpectedly.
2025-01-31T15:37:55.1354221Z 
2025-01-31T15:37:55.1355198Z Using `cy.origin()` to wrap the commands run on `https://example.cypress.io` will likely fix this issue.
2025-01-31T15:37:55.1355819Z 
2025-01-31T15:37:55.1356225Z `cy.origin('https://example.cypress.io', () => {`
2025-01-31T15:37:55.1356896Z `  <commands targeting https://example.cypress.io go here>`
2025-01-31T15:37:55.1357476Z `})`
2025-01-31T15:37:55.1357639Z 
2025-01-31T15:37:55.1358148Z https://on.cypress.io/cy-visit-succeeded-but-commands-fail�[0m�[90m
2025-01-31T15:37:55.1359031Z       at cypressErr (https://github.com/__cypress/runner/cypress_runner.js:75107:18)
2025-01-31T15:37:55.1359961Z       at Object.errByPath (https://github.com/__cypress/runner/cypress_runner.js:75161:10)
2025-01-31T15:37:55.1361107Z       at Object.commandCanCommunicateWithAUT (https://github.com/__cypress/runner/cypress_runner.js:144833:90)
2025-01-31T15:37:55.1362201Z       at <unknown> (https://github.com/__cypress/runner/cypress_runner.js:131753:22)
2025-01-31T15:37:55.1363137Z       at Object.subjectFn (https://github.com/__cypress/runner/cypress_runner.js:143657:16)
2025-01-31T15:37:55.1364201Z       at $Cy.verifyUpcomingAssertions (https://github.com/__cypress/runner/cypress_runner.js:142996:31)
2025-01-31T15:37:55.1365221Z       at onRetry (https://github.com/__cypress/runner/cypress_runner.js:143648:15)
2025-01-31T15:37:55.1366654Z       at tryCatcher (https://github.com/__cypress/runner/cypress_runner.js:1777:23)
2025-01-31T15:37:55.1367654Z       at Promise.attempt.Promise.try (https://github.com/__cypress/runner/cypress_runner.js:4285:29)
2025-01-31T15:37:55.1368639Z       at whenStable (https://github.com/__cypress/runner/cypress_runner.js:143535:68)
2025-01-31T15:37:55.1369478Z       at <unknown> (https://github.com/__cypress/runner/cypress_runner.js:143476:14)
2025-01-31T15:37:55.1370341Z       at tryCatcher (https://github.com/__cypress/runner/cypress_runner.js:1777:23)
2025-01-31T15:37:55.1371397Z       at Promise._settlePromiseFromHandler (https://github.com/__cypress/runner/cypress_runner.js:1489:31)
2025-01-31T15:37:55.1372526Z       at Promise._settlePromise (https://github.com/__cypress/runner/cypress_runner.js:1546:18)
2025-01-31T15:37:55.1373445Z       at Promise._settlePromise0 (https://github.com/__cypress/runner/cypress_runner.js:1591:10)
2025-01-31T15:37:55.1374440Z       at Promise._settlePromises (https://github.com/__cypress/runner/cypress_runner.js:1671:18)
2025-01-31T15:37:55.1375431Z       at Promise._fulfill (https://github.com/__cypress/runner/cypress_runner.js:1615:18)
2025-01-31T15:37:55.1376515Z       at <unknown> (https://github.com/__cypress/runner/cypress_runner.js:5420:46)
2025-01-31T15:37:55.1377162Z   From Your Spec Code:
2025-01-31T15:37:55.1377728Z       at Context.eval (webpack://example-basic/./cypress/e2e/spec.cy.js:5:7)
2025-01-31T15:37:55.1378431Z �[0m
2025-01-31T15:37:55.1378600Z 
2025-01-31T15:37:55.1378606Z 
2025-01-31T15:37:55.1378728Z 
2025-01-31T15:37:55.1380313Z �[31m  (�[4m�[1mResults�[22m�[24m)�[39m

On GitHub Actions in the regular log, the colors are interpreted.

See https://github.com/MikeMcC399/github-action/actions/runs/13075923590/job/36487946866 for logs.

I'm an external contributor and I don't have privileges in this repo to close other user's issues. My advice though is that it is not a documentation issue, nor a Cypress bug.

@jennifer-shehane
Copy link
Member

https://docs.cypress.io/app/continuous-integration/overview#Colors

If you want colors to be disabled, you can pass the NO_COLOR environment variable to disable colors. You may want to do this if ASCII characters or colors are not properly formatted in your CI.

@jennifer-shehane jennifer-shehane closed this as not planned Won't fix, can't repro, duplicate, stale Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants