Cypress

Custom command for disposable inboxes.

// cypress/support/ephemail.js
import { Ephemail } from "@ephemail/sdk";
const ephemail = new Ephemail({ apiKey: Cypress.env("EPHEMAIL_KEY") });

Cypress.Commands.add("freshInbox", () => cy.wrap(ephemail.addresses.create({ ttlSeconds: 600 })));
Cypress.Commands.add("waitOtp", (email) =>
  cy.wrap(ephemail.addresses(email).waitForMessage({ matchSubject: /verify/i, withOtp: true })),
);

it("signs up", () => {
  cy.freshInbox().then((a) => {
    cy.visit("/signup");
    cy.get("[name=email]").type(a.email);
    cy.contains("Sign up").click();
    cy.waitOtp(a.email).then((m) => cy.get("[name=otp]").type(m.otp));
    cy.contains("Welcome");
  });
});