Building End-to-End Cypress Tests Across Browser, API, and Worker Boundaries
A React support console displays Refund approved. The Cypress test sees the banner and passes.
The customer still has no refund.
The failure is not necessarily in the assertion. The assertion observed exactly what it was written to observe: the browser rendered a successful state. The application, however, spans more than the browser. A write may fail after an optimistic update. A queue may accept a message that no worker processes. An audit event may never be emitted.
For workflows with real consequences, I find it useful to treat the system as three independent witnesses.
- UI:Question it answers: What did the user see?; Typical assertion: Banner, route, enabled state
- Durable state:Question it answers: What did the system commit?; Typical assertion: REST or GraphQL response
- Side effect:Question it answers: What happened afterward?; Typical assertion: Audit entry, queued notification, webhook
Agreement among all three is stronger evidence than...
Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE