cypress-receivemail
v0.1.1
Published
Cypress commands for reading verification emails from a free disposable inbox (receivemail.dev) — no signup, no API key.
Maintainers
Readme
cypress-receivemail
Cypress commands for reading verification emails in end-to-end tests, backed by receivemail.dev — a free disposable inbox with no signup and no API key.
Test the parts of a signup flow that usually go untested: the "confirm your email" link, the emailed login code, the password-reset mail.
Install
npm i -D cypress-receivemailSet up
In cypress/support/e2e.{js,ts}:
import { addReceivemailCommands } from "cypress-receivemail";
addReceivemailCommands(); // or addReceivemailCommands({ ttlMinutes: 30 })Use
it("a new user can verify their email", () => {
cy.createMailbox().then((mb) => {
cy.visit("/signup");
cy.get("input[name=email]").type(mb.address);
cy.get("input[name=password]").type("test-Pa55w0rd");
cy.contains("button", "Create account").click();
// pull the verification link out of the email
cy.getEmailMatch(/https:\/\/[^\s"]+\/verify[^\s"]*/, {
subjectContains: "verify",
timeout: 30_000,
}).then((link) => {
cy.visit(link);
cy.contains("Email verified").should("be.visible");
});
});
});Numeric code instead of a link:
cy.getEmailMatch(/\b\d{6}\b/).then((code) => {
cy.get("input[name=code]").type(code);
});Whole message:
cy.waitForEmail({ fromContains: "noreply@yourapp" }).then((msg) => {
cy.log(msg.subject ?? "(no subject)");
});Commands
| Command | Description |
| --- | --- |
| cy.createMailbox(config?) | Create a fresh @receivemail.dev address; yields { address, expiresAt, secret } and makes it the current mailbox. |
| cy.waitForEmail(options?) | Poll the current mailbox until a matching message arrives; yields it, or fails on timeout. |
| cy.getEmailMatch(regex, options?) | waitForEmail then yield the first body substring matching regex. |
WaitForEmailOptions: timeout (default 30000), interval (default 2000),
subjectContains, fromContains. Only mail that arrives after cy.createMailbox
is matched, so a reused address won't return stale mail.
config (on addReceivemailCommands or per cy.createMailbox): ttlMinutes
(1–60, default 15), baseUrl (default https://receivemail.dev).
Limits
Mailbox creation is rate-limited to 20/min per IP; mailboxes live at most 60 minutes. For an SMS code instead, see sms-florin. There's also a Playwright version.
Coming from another tool?
Side-by-side comparisons, with each vendor's current pricing: MailSlurp · Mailosaur · Mailinator · Mailsac
License
MIT
