Skip to content

A Cypress test that signs up with a fresh address and opens the verification link from the email. The proxymail-qa package adds cy.proxymail, which has the Node.js client’s methods, from version 0.13.0.

  1. Add proxymail-qa to the project.

    npm install --save-dev proxymail-qa
  2. Each cy.proxymail command runs in Node through one Cypress task, so the API key stays out of the browser. It comes from PROXYMAIL_QA_API_KEY in the environment Cypress runs in.

    cypress.config.ts
    import { defineConfig } from 'cypress';
    import { setupProxyMailQA } from 'proxymail-qa/cypress/plugin';
    export default defineConfig({
    e2e: {
    setupNodeEvents(on) {
    setupProxyMailQA(on); // reads PROXYMAIL_QA_API_KEY
    },
    },
    });
  3. Import the commands in the support file.

    cypress/support/e2e.ts
    import 'proxymail-qa/cypress';
  4. Sign up with the address, then open the link from the email.

    For a code instead of a link, cy.proxymail.waitForCode(address, { since }) and type its value into the form.

    cypress/e2e/signup.cy.js
    it('verifies the email', () => {
    cy.proxymail.createAddress({ persona: true }).then(({ address, persona }) => {
    const since = new Date().toISOString();
    cy.visit('/signup');
    cy.get('[name=email]').type(address);
    cy.get('[name=name]').type(`${persona.first_name} ${persona.last_name}`);
    cy.contains('Sign up').click();
    cy.proxymail.waitForLink(address, { type: 'verify', since }).then(({ value }) => cy.visit(value));
    cy.proxymail.deleteAddress(address);
    });
    });

Waits get as long as their timeout (30 seconds unless you give one) and a margin, so Cypress’s task timeout doesn’t cut them short. In a run (the GitHub Action sets PROXYMAIL_QA_RUN), each call says which test it came from, so the run’s report shows which test each email came from.

cy.proxymail has every client method except withAccount, whose hooks are functions, and a run’s start and finish, which belong in your CI job or setupNodeEvents.

For a form that asks more than the email, such as a username, a team size or “How did you hear about us?”, call cy.proxymail.formValues({ fields, address, site, page }) and type in what comes back. The project’s custom fields fill your app’s own fields, and fields nobody taught get a guess to check (kind: 'guess'). For a sign-up over several screens, call it once per screen with the same address and that screen’s site and page.

If nothing arrives, the error says why as far as Proxy Mail QA can tell, for example that your app’s email provider only sends to verified addresses. For running in CI, see Running in CI. Prefer plain HTTP from the spec with cy.request? Every call is in the REST API guide.