Skip to content

Commit

Permalink
chore: [Multi-domain] Reset timeout after transition from before to…
Browse files Browse the repository at this point in the history
… `it` while unstable. (#21032)

* chore: [Multi-domain] Reset timeout after transition from before block to it block while unstable.

* enable clear timeout

* Adding tests and a comment

* Update packages/driver/src/cypress/command_queue.ts

Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>

* Move tests to their own file.

Co-authored-by: Chris Breiding <chrisbreiding@users.noreply.github.com>
  • Loading branch information
mjhenkes and chrisbreiding authored Apr 13, 2022
1 parent 663e5d5 commit dd3557f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/driver/cypress/integration/e2e/stability_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
describe('stability', () => {
describe('transitioning from a before block to an it block while unstable', () => {
beforeEach(() => {
cy.visit('/fixtures/auth/index.html')
cy.window().then((win) => {
win.location.href = 'http://localhost:3500/timeout?ms=1000'
})
})

it('fails if the page does not load within the page load timeout', { defaultCommandTimeout: 50, pageLoadTimeout: 500 }, (done) => {
cy.on('fail', (err) => {
expect(err.message).to.include(`Timed out after waiting \`500ms\` for your remote page to load.`)
done()
})

cy.get('[data-cy="login-idp"]').click() // Takes you to idp.com
})

it('waits for the page to load before running the command', { defaultCommandTimeout: 50 }, () => {
cy.get('body').invoke('text').should('equal', 'timeout')
})

it('will retry and fail the command after the page loads', { defaultCommandTimeout: 50 }, (done) => {
cy.on('fail', (err) => {
expect(err.message).to.include(`Timed out retrying after 50ms: expected 'timeout' to equal 'not timeout'`)
done()
})

cy.get('body').invoke('text').should('equal', 'not timeout')
})
})
})
6 changes: 6 additions & 0 deletions packages/driver/src/cypress/command_queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ export class CommandQueue extends Queue<Command> {
// store the previous timeout
const prevTimeout = this.timeout()

// If we have created a timeout but are in an unstable state, clear the
// timeout in favor of the on load timeout already running.
if (!cy.state('isStable')) {
cy.clearTimeout()
}

// store the current runnable
const runnable = this.state('runnable')

Expand Down

3 comments on commit dd3557f

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on dd3557f Apr 13, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.6.0/linux-x64/feature-multidomain-dd3557f5f32ba951296bafcf0f6e17db9c10febe/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on dd3557f Apr 13, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.6.0/win32-x64/feature-multidomain-dd3557f5f32ba951296bafcf0f6e17db9c10febe/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on dd3557f Apr 13, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.6.0/darwin-x64/feature-multidomain-dd3557f5f32ba951296bafcf0f6e17db9c10febe/cypress.tgz

Please sign in to comment.