Skip to content

Commit

Permalink
test(e2e): remove unnecessary wait after cy.visit
Browse files Browse the repository at this point in the history
This patch removes a now unnecessary wait after the `cy.visit()` call.
The upstream issue has been resolved in Cypress 12.

Ref: cypress-io/cypress#7306
Ref: cypress-io/cypress#7306 (comment)
  • Loading branch information
nicholaschiang committed Aug 11, 2023
1 parent 9fcbb96 commit 6d3a9b4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
4 changes: 2 additions & 2 deletions cypress/e2e/smoke.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('smoke tests', () => {
password: faker.internet.password(),
}

cy.visitAndCheck('/')
cy.visit('/')
cy.findByRole('link', { name: /log in/i }).click()
cy.findByRole('link', { name: /sign up/i }).click()

Expand Down Expand Up @@ -66,7 +66,7 @@ describe('smoke tests', () => {
content: faker.lorem.paragraph(),
}
cy.login()
cy.visitAndCheck('/shows')
cy.visit('/shows')

cy.findByRole('link', { name: /hermès/i })
.should('have.length', 1)
Expand Down
23 changes: 0 additions & 23 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ declare global {
* cy.resetDatabase()
*/
resetDatabase: typeof resetDatabase

/**
* Extends the standard visit command to wait for the page to load
*
* @returns {typeof visitAndCheck}
* @memberof Chainable
* @example
* cy.visitAndCheck('/')
* @example
* cy.visitAndCheck('/', 500)
*/
visitAndCheck: typeof visitAndCheck
}
}
}
Expand Down Expand Up @@ -93,17 +81,6 @@ function resetDatabase() {
cy.exec('pnpm prisma migrate reset --force')
}

// We're waiting a second because of this issue happen randomly
// https://github.com/cypress-io/cypress/issues/7306
// Also added custom types to avoid getting detached
// https://github.com/cypress-io/cypress/issues/7306#issuecomment-1152752612
// ===========================================================
function visitAndCheck(url: string, waitTime: number = 1000) {
cy.visit(url)
cy.location('pathname').should('contain', url).wait(waitTime)
}

Cypress.Commands.add('login', login)
Cypress.Commands.add('resetDatabase', resetDatabase)
Cypress.Commands.add('cleanupUser', cleanupUser)
Cypress.Commands.add('visitAndCheck', visitAndCheck)

0 comments on commit 6d3a9b4

Please sign in to comment.