Skip to content

Commit

Permalink
fix: ensure we have marked things as stable prior to after/afterEach …
Browse files Browse the repository at this point in the history
…hooks running (#30536)

* fix: ensure we have marked things as stable prior to failing tests -- run ci

* fix: ensure we have marked things as stable prior to failing tests -- run ci

* add a test -- run ci

* clean up

* add changelog

* Update CHANGELOG.md

* Apply suggestions from code review

* Update cli/CHANGELOG.md

Co-authored-by: Matt Schile <mschile@cypress.io>

* allow failure

---------

Co-authored-by: Jennifer Shehane <jennifer@cypress.io>
Co-authored-by: Matt Schile <mschile@cypress.io>
  • Loading branch information
3 people authored Nov 4, 2024
1 parent b0b28d3 commit a8a3cb9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

_Released 11/5/2024 (PENDING)_

**Bugfixes:**

- Fixed an issue where the Cypress runner could hang in `after` or `afterEach` hooks that run Cypress commands after a page load timeout error occurs. Addresses [#30238](https://github.com/cypress-io/cypress/issues/30238).

**Misc:**

- Fixed a typo in CLI `global` option help text. Addresses [#30531](https://github.com/cypress-io/cypress/issues/30531).
Expand Down
34 changes: 34 additions & 0 deletions packages/driver/cypress/e2e/issues/30238.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
after(() => {
// ensure that we're stable in the after hooks
expect(cy.state('isStable')).to.be.true

// ensure we can enqueue a command without timing out
cy.then(() => {
expect(true).to.be.true
})
})

afterEach(() => {
// ensure that we're stable in the after hooks
expect(cy.state('isStable')).to.be.true

// ensure that we can enqueue a command without timing out
cy.then(() => {
expect(true).to.be.true
})
})

it('runs an after block without timing out when the page load times out', { pageLoadTimeout: 500 }, () => {
cy.on('fail', (error) => {
expect(error.message).to.include('Timed out after')

return false
})

cy.on('window:before:load', (win) => {
// Stop the page from loading so that the page load times out
win.stop()
})

cy.visit('/fixtures/generic.html')
})
3 changes: 3 additions & 0 deletions packages/driver/src/cypress/command_queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ export class CommandQueue extends Queue<$Command> {
// end in case we have after / afterEach hooks
// which need to run
this.index = this.length

// Mark the state as stable, so that any cypress commands can be re-queued during the after / afterEach hooks
this.state('isStable', true)
}

private runCommand (command: $Command) {
Expand Down

5 comments on commit a8a3cb9

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a8a3cb9 Nov 4, 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.15.2/linux-x64/develop-a8a3cb9c8cafb4309708126af24bf8eedfe5119b/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a8a3cb9 Nov 4, 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.15.2/linux-arm64/develop-a8a3cb9c8cafb4309708126af24bf8eedfe5119b/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a8a3cb9 Nov 4, 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.15.2/darwin-arm64/develop-a8a3cb9c8cafb4309708126af24bf8eedfe5119b/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a8a3cb9 Nov 4, 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 win32 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.15.2/win32-x64/develop-a8a3cb9c8cafb4309708126af24bf8eedfe5119b/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a8a3cb9 Nov 4, 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.15.2/darwin-x64/develop-a8a3cb9c8cafb4309708126af24bf8eedfe5119b/cypress.tgz

Please sign in to comment.