cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.67k stars 3.16k forks source link

cy.session: validate function fails when expanding the log on Test Runner UI sidebar while the test is still running #29130

Open natashaw opened 6 months ago

natashaw commented 6 months ago

Current behavior

It seems that I have to avoid clicking the logs of cy.session in Test Runner UI so that the validate function won't throw an error

Error message:

CypressError: `cy.then()` timed out after waiting `8000ms`.

Your callback function returned a promise that never resolved.

The callback function was:

status => {
          return (0,_utils__WEBPACK_IMPORTED_MODULE_6__.navigateAboutBlank)().then(() => {
            setSessionLogStatus(status);
          });
        }

Because this error occurred during a `before each` hook we are skipping the remaining tests in the current suite: `[REDACTED]`
    at <unknown> (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:118229:75)
    at tryCatcher (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:1807:23)
    at <unknown> (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:4186:41)
    at tryCatcher (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:1807:23)
    at Promise._settlePromiseFromHandler (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:1519:31)
    at Promise._settlePromise (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:1576:18)
    at Promise._settlePromise0 (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:1621:10)
    at Promise._settlePromises (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:1697:18)
    at _drainQueueStep (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:2407:12)
From previous event:
    at Promise.longStackTracesCaptureStackTrace [as _captureStackTrace] (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:3486:19)
    at Promise._then (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:1239:17)
    at Promise.then (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:1132:17)
    at CommandQueue.runCommand (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:143427:8)
    at next (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:143627:19)
    at <unknown> (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:143648:16)
    at tryCatcher (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:1807:23)
    at Promise._settlePromiseFromHandler (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:1519:31)
    at Promise._settlePromise (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:1576:18)
    at Promise._settlePromise0 (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:1621:10)
    at Promise._settlePromises (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:1701:18)
    at _drainQueueStep (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:2407:12)
    at _drainQueue (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:2400:9)
    at Async._drainQueues (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:2416:5)
    at Async.drainQueues (http://[REDACTED].localhost:3001/__cypress/runner/cypress_runner.js:2286:14)

Screenshot:

12ce32ba7c22cded71c740f0645e3e00f75f7aac212be32923f964cc1b0ebc3a

Desired behavior

Not throwing an error or disable expanding cy.session logs while the test is running in Test Runner UI

Test code to reproduce

The issue actually occurs every time the log is expanded, regardless of the test code, but here's a dummy test code to reproduce anyway

const navigateToPage = () => {
    cy.session('navigateToPage', () => {
      cy.visit('https://example.com/')
    }, {
      validate () {
        cy.get('h1').should('be.visible')
      }
    })
})

beforeEach(() => {
    navigateToPage()
})

it('stays on the page after a reload', () => {
    cy.reload()
    cy.get('body').should('be.visible')
})

Cypress Version

12.17.4

Node version

v20.11.1

Operating System

12.5.1 (21G83)

Debug Logs

No response

Other

No response

jennifer-shehane commented 5 months ago

This seems to just fail the second time you run it, regardless of if you click on it or not.