Skip to main content

Pattern: Cypress tasks

Cypress tests run in the browser — they cannot make cross-origin API calls directly. Use Cypress tasks to call the TempInbox API from the Node.js process instead.

Setup: cypress/support/tasks.ts

cypress/support/tasks.ts

Register tasks: cypress.config.ts

cypress.config.ts

Example test

cypress/e2e/signup.cy.ts

Increasing task timeout

Cypress tasks have a default timeout of 60 seconds. For slow staging environments:

Tips

Use cy.wrap(jwt).as('jwt') or pass it through the test via closures — don’t rely on Cypress.env for per-test values.
Each spec creates its own inbox — parallel Cypress workers won’t collide.
This approach hits real SMTP. You catch real delivery failures that mocks would hide.