Skip to content
Discussion options

You must be logged in to vote

Short version: control the network for most tests, keep a few tests against the real API, and never wait on time, only on state.

1. Use cy.intercept() to make responses deterministic.

cy.intercept('GET', '/api/orders*', { fixture: 'orders.json' }).as('orders')
cy.visit('/orders')
cy.wait('@orders')
cy.get('[data-cy=order-row]').should('have.length', 3)

Most UI tests don't need the real backend. Stubbing removes the "different data in CI" and "slow API" problems in one go. For a few critical flows, keep end-to-end tests against a real (seeded) API, so the stubs can't hide a contract change.

2. Wait on aliases and assertions, not cy.wait(ms). cy.wait('@alias') waits for the actual request, …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by iamqa4
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants