Skip to content

proxymail-qa wraps the REST API for JavaScript and TypeScript: Playwright, Cypress, Vitest, Jest, Detox or a plain script. It has no dependencies, ships its own types, and runs on Node 18 or later (or anywhere with fetch). The source is at github.com/aaquib90/proxymail-qa-js, and each release is published from GitHub Actions with npm provenance.

  1. npm install --save-dev proxymail-qa
  2. Create an API key and set it as PROXYMAIL_QA_API_KEY, or pass it in.

  3. Create an address, sign up with it in your app, then wait for the code or link.

    Waits return the code or link on its own, with the service that sent it and when it expires, never the email’s text. A wait holds for up to 30 seconds and longer timeouts repeat it.

    import { ProxyMailQA } from 'proxymail-qa';
    const qa = new ProxyMailQA(); // reads PROXYMAIL_QA_API_KEY
    const { address, persona, password } = await qa.createAddress({ persona: true, password: true });
    const submitted = new Date();
    // …sign up in your app with address, persona and password…
    const { value: code } = await qa.waitForCode(address, { since: submitted });
    // or: const { value: link } = await qa.waitForLink(address, { type: 'verify', since: submitted });
    await qa.deleteAddress(address);

Full examples: Playwright and Cypress, whose cy.proxymail commands have these methods. The same package has a command for terminals, npm scripts and CI: npx proxymail-qa new.

Method What it does
new ProxyMailQA({ apiKey?, baseUrl?, fetch?, run? }) The client. apiKey defaults to PROXYMAIL_QA_API_KEY, and run to PROXYMAIL_QA_RUN
createAddress(options?) A new test address. Options: label, name (a custom name before the @; generic names such as test on their own are refused), persona, password (returned once, and typed as a string when you pass password: true), lifetimeDays, domain, age or dateOfBirth, country, and where it’s used: site and environment (new in 0.9.0)
waitForCode(address, options?) The newest verification or login code. Options: since, service, timeout (seconds, default 30), unused (skip codes already used: returned by an earlier wait, or copied or filled in the app or Proxy Mail QA for Chrome; new in 0.5.1), and type: 'coupon' for a coupon or promo code, with its discount, valid_until and after_seconds (new in 0.10.0). New in 0.13.0: expectSite, and link_site on the match, which says whether the email’s links go back to the site the test started on (Links to the wrong site). When a wait without since or unused returns a code that was already used, the match has a note saying how to get a newer one
waitForLink(address, options?) The same for a link. Also type (verify, magic_signin, invite, reset or any, or a list) and app (true for the link that opens a mobile app). When a wait without since or unused returns a link that was already used, the match has a note saying how to get a newer one
messages(address, options?) Emails with their codes and links. includeText and includeHtml add the content, for template tests; limit
countEmails(address, options?) How many emails arrived, each summarised without its content. Options: since, service, type (code or link), subtype and, from 0.10.0, category (auth, transactional or marketing)
findEmails(options?) The emails that reached any address in the project, newest first, each with its address, sender, subject and From, and a count of those that match (up to 10,000). Options: within ('10m', '2h', up to 30 days) or since and until, category, service, type, subtype, subject (a phrase the subject contains, in any case), limit (1 to 100, default 20) and before, for the next page. With no since or within, the last 30 days. From 0.16.0. Doesn’t wait (more)
expectNoEmail(address, options?) Resolves if no matching email arrives within timeout seconds (default 30, and minutes work: it asks again); throws ProxyMailQAError (409, email_arrived) as soon as one does. Same filters, and since defaults to now
markUnsubscribed(address, options?) Marketing. Records that the address unsubscribed from a sender (emailId or service; at to backdate; grace: '1d' for mail already on its way), after the test did it in its browser. Any later marketing email from that sender fails after_unsubscribe. New in 0.10.0
markResubscribed(address, options?) Marketing. The address subscribed again: ends the watch. New in 0.10.0
recordConsent(address, consent) Marketing. Records what the account agreed to at sign-up (marketing, prechecked, doubleOptIn), for the marketing rules by country. consent(address) reads it. New in 0.10.0
consent(address) Marketing. What the account agreed to, as recorded. New in 0.10.0
recordCouponResult(address, result, options?) Offers. After applying a coupon at checkout (staging, test payments), records accepted, rejected or error with the app’s message (code, oneTime); check is the coupon_result verdict. New in 0.10.0
checkSequence(address, steps, options?) Marketing. Whether a welcome series or drip campaign came in order and on time after since; each step can give subject, category, type, after (‘1d’) and within. New in 0.10.0
offers(address) Offers. Each sender’s coupons and which version of the address (plain, capitals, +tag) each went to; passed is false when one person got an offer twice. New in 0.10.0
checkUnsubscribe(address) Marketing. Each unsubscribe and the marketing emails that came after it; passed is false when any did. New in 0.10.0
forTest(name), recordTest(result), recordTestTotals(totals) A client that names its test in every call, and test results for the run’s report; proxymail-qa/playwright and its reporter use them. New in 0.8.0 (more)
formValues({ fields, address?, age?, country?, … }) What to type or pick in each field of a sign-up form, from a new address made for it. New in 0.7.0 (more). From 0.12.0 the form’s own fields too: page, screen and guess, each field’s testId, htmlId, min, max, step and required, and the kinds custom and guess (more). From 0.13.0 kycSandbox and kycOutcome, for a KYC vendor’s sandbox values (kind sandbox)
customFields(), saveCustomField(field), setCustomFieldEnabled(id, on), deleteCustomField(id) List, add or change, turn on or off, and remove the project’s custom fields. Where only leads change them and your key’s creator isn’t one, saving, turning on or off, or removing asks the leads instead (status: 'requested'). New in 0.12.0
setStandardField(field, on) Turns 'company', 'first_name', 'last_name' or 'full_name' on or off. When one is off, that box is left empty, unless a custom field that’s on fills it. Where only leads change custom fields and your key’s creator isn’t one, this asks the leads instead (status: 'requested'). New in 0.12.0
sites(), addSite(site, environment), setMultiStep(site, on), saveSignupScreen({ site?, page?, screen?, label? }), removeSignupScreen(id) The project’s sites with whether each screen of a sign-up fills by itself there (multi_step) and their sign-up screens; add a site that doesn’t look live, such as staging.example.com or localhost:3000 (one that looks live is refused with a link for a person to add it in the app); turn Sign-up goes over several screens on or off; add, keep, name or remove a sign-up screen. Where only leads change sites and your key’s creator isn’t one, changes ask the leads instead (status: 'requested'). New in 0.12.0 (more)
checkEmail(address, options?) Checks the newest matching email (or emailId): SPF, DKIM, DMARC, local and plain http links, where its link goes (expectHost), whether it goes back to the site the test started on (link_site, with expectSite from 0.13.0), a stated expiry (and, from 0.10.0, when a coupon ends), a plain-text part, size and image-only emails. From 0.7.0, phrases it should contain (expectText) and its language (expectLanguage); from 0.10.0, how soon after since it came (expectWithin: '5m') and its attachments (expectAttachment: ['.pdf']). A marketing email also gets list_unsubscribe, one_click_unsubscribe, unsubscribe_link and preheader, and every email harmful_attachment and spam_risk (an estimate of whether it lands in spam; from 0.15.0 its inbox_score is out of 10, where 10 is good, and the older score is deprecated). Verdicts only, never its content. New in 0.4.0
checkDelivery(address) What reached the address and what was refused, without waiting
variants(address) Unusual versions of the address that still get its mail, and invalid ones (more)
nameVariants({ field?, maxLength? }) Awkward names for a name field: ones to accept (apostrophes, accents, other scripts), ones to reject, HTML or SQL to store as text, and ones apps differ on. New in 0.11.0 (more)
passwordVariants({ minLength?, maxLength?, symbols? }) Awkward passwords within the field’s rules: the minimum and maximum, each symbol class, spaces, non-ASCII, and ones apps differ on; fresh each call. New in 0.11.0 (more)
signupForms(), signupForm(id), saveSignupForm(spec, id?), deleteSignupForm(id, { removeCustomFields? }) List, read, save and remove the project’s sign-up forms. Saving makes the custom fields the form needs, and removeCustomFields: true removes them with the form; where only leads change custom fields and your key’s creator isn’t one, it asks the leads instead (status: 'requested'). New in 0.13.0 (more)
signupFormCode(id, { format?, requested? }) A sign-up form as code for your app: format 'react-hook-form' (default), 'react' or 'html'. Gives files, dependencies and notes. New in 0.13.0
signupFormTest(id, { framework?, requested? }) Tests for a sign-up form: framework 'playwright' (default) or 'cypress'. Each field gets values the form should take and ones it should refuse. Gives files, dependencies, counts and notes. New in 0.13.0
listFormSections({ country?, group?, kycSandbox?, kycOutcome? }) The field sections a sign-up form may ask for, with labels in nine languages and, for ID and tax numbers, the countries with formats. New in 0.13.0 (more)
signupStarters({ id?, language?, country? }) Starters to build a sign-up form from, each with notes and its spec. New in 0.13.0 (more)
getFormSection(id, { country?, address?, kycSandbox?, kycOutcome? }) One section: for an ID or tax number, its format in a country, a fake value that follows it, given only where one can never be a real person’s, and variants; a passport (Utopia by default) comes with its machine-readable lines; kycSandbox and kycOutcome add a KYC vendor’s own sandbox values. New in 0.13.0 (more)
followsFormat(format, value) Whether a value follows a format from getFormSection, its shape and check digit, worked out here so an ID never leaves your machine. New in 0.13.0
cleanupList({ from?, to?, site? }) Every test address the project used between from and to (Dates or ISO text; 30 days ago to now by default, and from can’t go back past 90 days), live, expired or deleted, with mail_domains, to delete those test users from your app afterwards. New in 0.13.0 (more)
journey({ site?, phase?, country?, countryUnknown?, age?, ageUnknown?, anyTags?, address?, gotStep?, notGotStep? }) Labs: Journeys. A site’s journey, as the Journeys page draws it: the emails the project’s test accounts got from it, in order, with the waits between them, who got each one, who is still due it and its warnings. Starts with the page’s sentence and gives a link to the page on the same view. Where the map splits, journey(path.filter) shows one path alone. New in 0.14.0 (more)
flowChecks(flow) The checks to run on 'sign_up', 'password_reset' or 'magic_link' beyond the email arriving, each with steps, expect, why and, when it can’t always run, needs; your test runs them through the app. New in 0.13.0 (more)
getAddress(address), listAddresses({ limit?, before?, tags?, country?, minAge?, maxAge?, hasPassword?, search?, site?, environment? }) Read addresses, or find ones made earlier: every filter given must match
updateAddress(address, patch) Change label, notes, tags, first_name, last_name, username, date_of_birth or country, or where it’s used: site and environment; null clears one
setPassword(address, { password?, label? }) Save the password the test account uses now, after the app changed or reset it. Without one, a strong password is generated and returned once
savedPassword(address, label?) Read a saved password. Needs a key with “Can read saved passwords”; every read is logged
signInAccount({ site?, environment?, tags? }) The saved test account to sign in with, and its password, in one call: the one used on this site first; null when none fits. Needs a key with “Can read saved passwords”. New in 0.9.0 (more)
totpCode(secret, options?) An authenticator app’s code for a two-factor sign-in, worked out on your machine: see Two-factor codes. New in 0.13.0
markSubmitted(address, options?) Records that the test is about to submit the form, by the server’s clock: flow (sign_up, the default, sign_in, reset, magic_link or other) and site (the page). Call it just before the test presses the button, as the time is taken when the call arrives, and pass its submitted_at as since. A code or link that arrives after the mark has time_to_email in the wait’s match (Time to email). New in 0.13.0
markDevHost(host) Marks a host such as localhost:3000 as a dev environment of the project, so checkEmail passes links to it. New in 0.9.0
deleteAddress(address) Delete the address and its mail
project() The key’s project: its mail domains, email prefix and limits; from 0.12.0 its guesses setting (fill_unknown_fields), the standard fields turned off (standard_fields_off), whether it’s locked, how many custom_fields it has and its multi_step_sites; from 0.13.0 whether all five ID and tax number ready-made fields are on (fill_id_fields); from 0.15.0 whether its spam checks are on (spam_checks)
updateProject({ name?, website?, environments?, emailPrefix?, mailDomain?, fillUnknownFields?, fillIdFields?, areas?, spamChecks? }) Change the project, as in Project settings; null clears website or emailPrefix. Needs the project’s lead, or an organisation owner or admin. fillUnknownFields (all, required or off: which fields formValues guesses) follows the custom fields’ rules instead, new in 0.12.0. fillIdFields (true or false: whether the five ID and tax number ready-made fields are on, which fill a fake value only where one can never be a real person’s) is for the project’s leads only, new in 0.13.0. areas (the whole list of signup, offers, marketing and receipts, at least one) and spamChecks are what Project settings → What you test sets, for the project’s leads, new in 0.15.0
checkOutAccount({ tags?, country?, minAge?, maxAge?, hasPassword?, search?, site?, environment?, minutes? }), extendCheckout(account, minutes?), returnAccount(account, { addTags?, removeTags? }), withAccount(options, fn) The account pool: borrow an account in a known state that no other test has, and give it back. New in 0.6.0 (more). From 0.7.0, withAccount takes create, check and reset hooks: accounts in a known state
startRun({ name?, source?, meta? }), finishRun({ failed? }), runReport(), addRunNote(text, { failed? }), getRun(), listRuns() A run: this client’s calls add what they saw, for a report on the pull request. New in 0.5.0

Every method takes a plain address or a variant of it. Waiting on a +tag address only finds mail sent to that tag, so one address can serve a whole test run: see Running in CI.

Methods marked Offers or Marketing are for projects that test offers or marketing, set in the app under Project settings → What you test or with updateProject({ areas }). checkEmail leaves out the coupon and marketing checks when the project tests neither, and spam_risk and harmful_attachment when its spam checks are off (updateProject({ spamChecks })).

Methods marked Labs: Journeys are part of Journeys, a Labs feature the key’s creator switches on in the app under Account settings → Labs; until then they throw with a 403 that says so, and checkEmail leaves out Journeys’ five good-practice checks.

formValues gives what to type or pick in each field of a form, from a new address made for it: a username and password that fit the fields’ rules, the date of birth in the field’s format, a country the drop-down offers. In Playwright, read the fields from the page and fill each one in:

const form = page.locator('form#sign-up');
const fields = await form.locator('input, select').evaluateAll((elements) =>
elements.map((el, i) => {
const input = el as HTMLInputElement & HTMLSelectElement;
input.dataset.field = String(i);
// The label's own words in one line, up to 300 characters: a label around a drop-down also holds each option's text.
const label = input.labels?.[0]?.cloneNode(true) as HTMLLabelElement | undefined;
label?.querySelectorAll('select, textarea').forEach((inner) => inner.remove());
return {
id: String(i),
type: input.tagName === 'SELECT' ? 'select' : input.type,
name: input.name,
label: (label?.textContent ?? input.getAttribute('aria-label') ?? '').replace(/\s+/g, ' ').trim().slice(0, 300),
// A placeholder and each option's text up to 200 characters. A pattern over 500 is left out, as a cut one would be another rule.
placeholder: input.placeholder?.slice(0, 200),
autocomplete: input.getAttribute('autocomplete') ?? '',
pattern: input.pattern && input.pattern.length <= 500 ? input.pattern : undefined,
minLength: input.minLength > 0 ? input.minLength : undefined,
maxLength: input.maxLength > 0 ? input.maxLength : undefined,
options: input.tagName === 'SELECT' ? Array.from(input.options, (o) => ({ value: o.value, label: o.text.slice(0, 200) })) : undefined,
};
}),
);
const { address, values } = await qa.formValues({ fields });
for (const { id, kind, value } of values) {
if (value === null) continue;
const field = form.locator(`[data-field="${id}"]`);
if (await field.evaluate((el) => el.tagName === 'SELECT')) await field.selectOption(value);
else await field.fill(value);
}

Pass address to use an account made earlier, and age or country for a new one. With address, a later screen of the sign-up gets a password, date of birth or country only when the account has none yet. A sign-in or password reset form sent without address is refused (409) instead of making an account; with address it gets only the email or username. More in the REST API guide.

From 0.12.0, formValues fills the form’s own fields too, such as company size or “How did you hear about us?” (more). A field one of the project’s custom fields decides comes back with kind: 'custom' and the custom field’s rule; a field nobody taught comes back with kind: 'guess' and where the guess came from, when the project guesses. Check the guesses suit your test before you submit. Send site and page on every call, later screens included, so custom fields for one site or page apply, required on the fields the form marks as required, and guess to override the project’s setting for one call. Send multiple: true on a drop-down that takes several answers, or a list the page draws itself that does, such as a box of chips: it comes back with value: null and the options to select in values, and only a custom field set to Several options fills it. Send each tick box as a field of its own, with group for the question they answer: each comes back with checked.

A sign-up over several screens: make the account on the first screen, then send each later screen’s fields with the same address and that screen’s site and page:

import type { Locator } from '@playwright/test';
import type { FormValue } from 'proxymail-qa';
const readFields = (form: Locator) =>
form.locator('input, select, textarea').evaluateAll((elements) =>
elements.map((el, i) => {
const input = el as HTMLInputElement & HTMLSelectElement;
input.dataset.field = String(i);
// The label's own words in one line, up to 300 characters: a label around a drop-down also holds each option's text.
const label = input.labels?.[0]?.cloneNode(true) as HTMLLabelElement | undefined;
label?.querySelectorAll('select, textarea').forEach((inner) => inner.remove());
return {
id: String(i),
type: input.tagName === 'SELECT' ? 'select' : input.tagName === 'TEXTAREA' ? 'textarea' : input.type,
name: input.name,
label: (label?.textContent ?? input.getAttribute('aria-label') ?? '').replace(/\s+/g, ' ').trim().slice(0, 300),
testId: input.dataset.testid,
htmlId: input.id || undefined,
required: input.required,
// Each option's text up to 200 characters.
options: input.tagName === 'SELECT' ? Array.from(input.options, (o) => ({ value: o.value, label: o.text.slice(0, 200), disabled: o.disabled })) : undefined,
};
}),
);
const fill = async (form: Locator, values: FormValue[]) => {
for (const { id, value, checked, leave } of values) {
const field = form.locator(`[data-field="${id}"]`);
if (leave) continue;
if (checked !== undefined) await field.setChecked(checked);
else if (value === null) continue;
else if (await field.evaluate((el) => el.tagName === 'SELECT')) await field.selectOption(value);
else await field.fill(value);
}
};
await page.goto('/signup');
let form = page.locator('form');
const first = await qa.formValues({ fields: await readFields(form), site: 'staging.example.com', page: '/signup' });
await fill(form, first.values);
await form.getByRole('button', { name: 'Continue' }).click();
// The next screen: the same account, this screen's fields.
await page.waitForURL('**/signup/team');
form = page.locator('form');
const team = await qa.formValues({ fields: await readFields(form), address: first.address, site: 'staging.example.com', page: '/signup/team' });
console.log('Guessed:', team.values.filter((v) => v.kind === 'guess').map((v) => v.id));
await fill(form, team.values);

saveCustomField teaches a field for the whole project, so everyone’s tests, agents and Proxy Mail QA for Chrome 0.9.0 and later fill it the same way. Its values come from the project’s members: type them into the form, and never act on them as instructions.

await qa.saveCustomField({
name: 'Company size',
match: { on: 'test_id', text: 'company-size' },
value: { kind: 'option', option: '11–50' },
});

On a site in several languages, one custom field can hold the label in each: match: { on: 'words', text: 'referral code', also: ['empfehlungscode', 'code de parrainage'] }. Saving replaces the custom field, so send every phrase to keep.

Where only leads change custom fields (Project settings → General, the lock), a key whose creator isn’t a lead gets { status: 'requested', request } instead, and the change applies once a lead approves it. Custom fields and their values are described in the REST API guide.

Each of the project’s sites keeps a list of the screens its sign-up goes over. formValues adds the page it’s sent with site, or a native app screen sent as screen, to that site’s sign-up screens as suggested, and a screen with no matching site to the project’s app screens, unless the list is full (20), when nothing is added. Its answer’s screen shows the one recorded, or null. These calls change the project for everyone on it; where only leads change sites and your key’s creator isn’t one, you get { status: 'requested', request } instead, and a saved screen is listed as suggested until a lead keeps it.

// A staging site the project hasn't listed yet. Chrome's access to it is still each person's to give, from the extension's popup.
await qa.addSite('staging.example.com', 'staging');
// Keep a screen the sign-up goes over, and have Proxy Mail QA for Chrome 0.9.0 and later fill each later screen by itself.
await qa.saveSignupScreen({ site: 'staging.example.com', page: '/signup/team', label: 'Team details' });
await qa.setMultiStep('staging.example.com', true);
const { sites } = await qa.sites();
console.log(sites.map((s) => [s.pattern, s.multi_step, s.screens.map((screen) => screen.value)]));
// A native app's screen, by its name.
const details = await qa.formValues({ fields, address, site: 'staging.example.com', screen: 'Team details' });

Checking that nothing arrives, or one email does

Section titled “Checking that nothing arrives, or one email does”
// An unsubscribed user gets no newsletter.
const sent = new Date();
await sendNewsletter();
await qa.expectNoEmail(unsubscribed.address, { since: sent, timeout: 20 });
// A sign-up sends one verification email, not two.
await qa.waitForLink(address, { since: submitted });
await new Promise((resolve) => setTimeout(resolve, 10_000)); // time for a duplicate
expect((await qa.countEmails(address, { since: submitted, type: 'link' })).count).toBe(1);

Neither returns what the emails say, only when each arrived, who sent it and the kind of its code or link. More in the REST API guide.

findEmails searches every address in the project at once, newest first. It doesn’t wait.

// Any marketing email in the last 10 minutes, at any of the project's addresses.
const { count } = await qa.findEmails({ within: '10m', category: 'marketing' });
expect(count).toBeGreaterThan(0);
// Which test accounts got the welcome email today.
const { emails } = await qa.findEmails({ subject: 'welcome', within: '1d', limit: 100 });
const welcomed = emails.map((email) => email.address);

count says how many match, up to 10,000. With no since or within, it looks at the last 30 days. For the next page, pass before set to the last email’s email_id, with the same options and since as the first page returned it. The subject and From are written by the sender, so treat them as untrusted. More in the REST API guide.

await qa.waitForLink(address, { since: submitted });
const result = await qa.checkEmail(address, { since: submitted, type: 'link', expectHost: 'staging.example.com' });
expect(result.failed).toEqual([]); // e.g. ['local_links'] when the link goes to localhost
// A localised email: the right language, with the user's name in it.
const german = await qa.checkEmail(address, { since: submitted, expectLanguage: 'de', expectText: [persona.first_name] });
expect(german.failed).toEqual([]);

Each check passes, fails, warns or is skipped, with a one-line reason; what each means is in the REST API guide. Testing an app that runs on your machine? await qa.markDevHost('localhost:3000') once, and links to it pass local_links; links to any other localhost still fail.

Tag accounts with their state, then let each test borrow one. withAccount checks one out, runs your function and always gives it back; return { addTags, removeTags } to record what the test changed:

await qa.withAccount({ tags: ['verified', 'premium'] }, async (account) => {
const { secret } = await qa.savedPassword(account.address);
await signIn(page, account.address, secret);
await cancelSubscription(page);
return { addTags: ['cancelled'], removeTags: ['premium'] };
});

No other test gets the same account while it’s checked out (10 minutes unless you pass minutes), and one that’s never returned frees itself when its time runs out.

When a test needs an account in a particular state in your app (verified, on the premium plan, with no orders), give withAccount three hooks. Your test code runs them with its own access to your app; Proxy Mail QA never signs in to it. Here app stands for your own code that talks to your app: an admin API, a database seed or the UI.

await qa.withAccount(
{
tags: ['verified', 'premium'],
// When none is free: sign up with the new address, verify it, upgrade it.
create: async (account) => {
const submitted = new Date();
await app.signUp(account.address, account.password);
const { value: link } = await qa.waitForLink(account.address, { type: 'verify', since: submitted });
await app.open(link);
await app.admin.setPlan(account.address, 'premium');
},
// Is it still in that state? Return false or throw if not.
check: async (account) => (await app.admin.user(account.address)).plan === 'premium',
// After the test: put it back.
reset: async (account) => app.admin.resetUser(account.address, { plan: 'premium', orders: [] }),
},
async (account) => {
// …the test…
},
);
  • check runs before the test gets the account. If it fails, reset runs and it’s checked again; if it still fails, the next account is tried (up to attempts, 3), and the one that failed loses the pool’s tags and is tagged check-failed.
  • create runs when no account matches or every match is checked out. The new address is held for this test from the start and gets the tags once create and check succeed. Pass newAccount for its age, label or domain; it gets the filter’s country.
  • reset runs after the test, whether it passed or not. If reset fails, the account loses the pool’s tags and is tagged needs-reset, so no other test gets it in an unknown state.

In a run, a new account, a failed check and a failed reset each add a line to the report.

Calls made while a run is open add what they saw to it: the addresses, which emails arrived and how long after since, the codes, where each link goes, checks, unsubscribe, offer and coupon checks, failed tests, and emails that never came. In GitHub Actions, the Proxy Mail QA action starts and finishes the run and posts the report on the pull request; the client picks the run up from PROXYMAIL_QA_RUN with no changes to your tests. Elsewhere, run it yourself:

const run = await qa.startRun({ name: 'Sign-up tests', meta: { branch: process.env.BRANCH } });
// …the tests, using qa…
await qa.finishRun({ failed: testsFailed });
console.log(await qa.runReport(run.id)); // Markdown, for a pull request comment

Other processes join the run when you pass them its id as PROXYMAIL_QA_RUN.

To show which test each email came from, use a client for each test: qa.forTest('sign-up › sends one code') names the test in every call. In Playwright, proxymail-qa/playwright gives every test a qa fixture that does this, and proxymail-qa/playwright/reporter records failed and flaky tests and the totals in the run: see Running in CI. Other test runners can send results themselves with qa.recordTest({ name, status, durationMs, error }) and qa.recordTestTotals({ passed, failed, skipped, flaky }). New in 0.8.0.

For a test account with two-factor sign-in, totpCode works out the authenticator app’s code on your machine from the secret the app showed when two-factor was set up: its base32 key, or the otpauth://totp/… address in its QR code. The secret never reaches Proxy Mail QA. Keep it where the test keeps its other secrets, such as a CI secret.

import { totpCode } from 'proxymail-qa';
const code = await totpCode(process.env.ACME_TOTP_SECRET!, { minSecondsLeft: 5 });
await page.getByLabel('Authentication code').fill(code);

The defaults are 6 digits, 30 seconds and SHA-1, which nearly every app uses; an otpauth:// address sets its own. minSecondsLeft waits for the next code when this one is about to run out, so it doesn’t expire before the app checks it. at works one out for another moment. It’s also on the client, as qa.totpCode(secret, options). New in 0.13.0.

Failed calls throw ProxyMailQAError with the HTTP status, a code and a readable message. When a wait finds nothing, the message also says why as far as Proxy Mail QA can tell (error.hint), for example that the app’s email provider only sends to verified addresses, and error.refused lists mail turned away for being too large, over a limit or from a site Proxy Mail QA doesn’t work with (refused[].site names it). New in 0.13.0: error.why says which case it is (nothing_arrived, or no_match when email arrived, so the app is sending) and error.sharedSender names a platform’s built-in sender and its cap, such as Bubble’s 20 emails a day (Did it send?):

import { ProxyMailQAError } from 'proxymail-qa';
try {
await qa.waitForCode(address, { since: submitted });
} catch (error) {
if (error instanceof ProxyMailQAError && error.status === 404) console.log(error.why, error.hint);
throw error;
}

Retrying won’t help until the app can send to any address. See Test email not arriving?

error.why can also be arrived_before_since: an unused code or link came shortly before since, and error.hint says when, so the test can wait again with an earlier since. The value already arrives; its type follows in the next release.

Tests and agents can come back to an account they made earlier instead of creating another. Every filter given must match; ages are whole years today, from the persona’s date of birth, and search looks in the address, label, notes, name and username.

// An under-18 in the UK, made for the age-gate tests, with a saved password.
const [teen] = await qa.listAddresses({ tags: ['age-gate'], country: 'GB', maxAge: 17, hasPassword: true });
// Record where an account is used, then sign in with it again later: the
// account used on this site first, with its password (needs a key with
// "Can read saved passwords").
await qa.createAddress({ password: true, site: 'staging.example.com', environment: 'staging' });
const account = await qa.signInAccount({ site: 'staging.example.com', tags: ['verified'] });