Skip to content

Commit

Permalink
test: fix driver reruns spec while recording due to weird reloading c…
Browse files Browse the repository at this point in the history
…ycle (#29183)

* chore: fix driver reruns test while recording due to weird reloading cycle

* Update rerun.cy.js

* Update packages/driver/cypress/e2e/e2e/rerun.cy.js

* PR comments

* Update rerun.cy.js
  • Loading branch information
ryanthemanuel committed Mar 26, 2024
1 parent 903ced2 commit 11c6dd8
Showing 1 changed file with 39 additions and 4 deletions.
43 changes: 39 additions & 4 deletions packages/driver/cypress/e2e/e2e/rerun.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,47 @@ if (window.top.runCount == null) {
window.top.runCount = 0
}

// This spec in the driver has some weird reloading that occurs. It triggers a simulation of
// essentially reloading the page in run mode and that effectively wipes away some state that we
// need for protocol. Rather than trying to handle this edge case in a complicated one-off fashion,
// just ensure that the protocol events fire for this one spec.
if (Cypress.config('browser').family === 'chromium') {
// Copied from:
// https://github.com/cypress-io/cypress-services/blob/825abbabaaa0a8ecf78e2ad543493a85a01a939f/packages/app-capture-protocol/src/cypress-events/track-cypress-events.ts#L17-L30
const getCypressProtocolElement = () => {
let cypressProtocolElement = window.top.document.getElementById('__cypress-protocol')

// If element does not exist, create it
if (!cypressProtocolElement) {
cypressProtocolElement = document.createElement('div')
cypressProtocolElement.id = '__cypress-protocol'
cypressProtocolElement.style.display = 'none'
window.top.document.body.appendChild(cypressProtocolElement)
}

return cypressProtocolElement
}

// Copied from:
// https://github.com/cypress-io/cypress-services/blob/825abbabaaa0a8ecf78e2ad543493a85a01a939f/packages/app-capture-protocol/src/cypress-events/track-cypress-events.ts#L38-L44
const attachCypressProtocolTestAfterRun = () => {
const cypressProtocolElement = getCypressProtocolElement()

cypressProtocolElement.dataset.cypressProtocolTestAfterRun = JSON.stringify({
timestamp: performance.now() + performance.timeOrigin,
})
}

// Copied from:
// https://github.com/cypress-io/cypress-services/blob/825abbabaaa0a8ecf78e2ad543493a85a01a939f/packages/app-capture-protocol/src/cypress-events/track-cypress-events.ts#L110-L112
Cypress.prependListener('test:after:run:async', () => {
attachCypressProtocolTestAfterRun()
})
}

const isTextTerminal = Cypress.config('isTextTerminal')

// TODO: UNSKIP this for chromium browsers. @see https://github.com/cypress-io/cypress/issues/29181
describe('rerun state bugs', { browser: {
family: '!chromium',
} }, () => {
describe('rerun state bugs', () => {
// NOTE: there's probably other ways to cause a re-run
// event more programatically (like firing it through Cypress)
// but we get the hashchange coverage for free on this.
Expand Down

4 comments on commit 11c6dd8

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 11c6dd8 Mar 26, 2024

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.7.2/linux-x64/develop-11c6dd80f1a870d1b07e2f87ddd392fcf358c525/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 11c6dd8 Mar 26, 2024

Choose a reason for hiding this comment

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

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.7.2/linux-arm64/develop-11c6dd80f1a870d1b07e2f87ddd392fcf358c525/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 11c6dd8 Mar 26, 2024

Choose a reason for hiding this comment

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

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.7.2/darwin-x64/develop-11c6dd80f1a870d1b07e2f87ddd392fcf358c525/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 11c6dd8 Mar 26, 2024

Choose a reason for hiding this comment

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

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.7.2/darwin-arm64/develop-11c6dd80f1a870d1b07e2f87ddd392fcf358c525/cypress.tgz

Please sign in to comment.