Skip to content

A Playwright test that signs up with a fresh address and enters the code from the email, using the proxymail-qa package.

  1. Add proxymail-qa to the project and keep the API key in PROXYMAIL_QA_API_KEY.

    npm install --save-dev proxymail-qa
  2. Create an address, sign up with it, then wait for the code.

    since makes the wait ignore anything sent before the form was submitted, so a retry never picks up an old code. Waits hold for up to 30 seconds; pass timeout for longer.

    signup.spec.ts
    import { expect, test } from '@playwright/test';
    import { ProxyMailQA } from 'proxymail-qa';
    const qa = new ProxyMailQA(); // reads PROXYMAIL_QA_API_KEY
    test('sign-up sends a working code', async ({ page }) => {
    const { address, password } = await qa.createAddress({ persona: true, password: true });
    const submitted = new Date();
    await page.goto('/signup');
    await page.getByLabel('Email').fill(address);
    await page.getByLabel('Password').fill(password);
    await page.getByRole('button', { name: 'Sign up' }).click();
    const { value } = await qa.waitForCode(address, { since: submitted });
    await page.getByLabel('Code').fill(value);
    await expect(page).toHaveURL(/welcome/);
    await qa.deleteAddress(address);
    });
  3. For a link instead of a code, wait for the link and go to it.

    const { value: link } = await qa.waitForLink(address, { type: 'verify', since: submitted });
    await page.goto(link);

When the sign-up also asks for a username, a team size or “How did you hear about us?”, send what the page says about each field to qa.formValues and fill in what comes back. The project’s custom fields fill your app’s own fields (kind: 'custom'), and fields nobody taught get a guess to check (kind: 'guess'). For a sign-up over several screens, make the account on the first screen, then call it once per screen with the same address and that screen’s site and page. A password the later screen asks for comes back in values when the first screen had none:

const first = await qa.formValues({ fields: signUpFields, site: 'staging.example.com', page: '/signup' });
// ...fill the first screen and press Continue, then on the next one:
const team = await qa.formValues({ fields: teamFields, address: first.address, site: 'staging.example.com', page: '/signup/team' });

The Node.js client has the whole test, with a helper that reads each screen’s fields.

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. The package also covers dates of birth and countries on personas, app links, the email’s HTML for template tests, and unusual addresses: see its README. For running in CI, see Running in CI.

Prefer plain HTTP? Every call is in the REST API guide.