Magic link testing
A shorter product overview for teams that want the workflow in one screen.
Open pageCypress
Use a PostMX inbox to capture the link your app sends, then continue the Cypress flow with the real URL instead of a stubbed response.
The shorter path is the better test: send the mail, read the link, visit it.
Why not mock it
Magic-link tests often fail in the gap between "the app says it sent the email" and "the user receives a valid URL." Using a live inbox keeps that gap visible, so template changes, routing mistakes, or expired links surface in the test suite instead of in production.
If the user will click a link that came by email, the test should wait for that link to arrive and then drive the browser with it. That is the behavior you want to trust.
Minimal Cypress flow
import { PostMX } from "postmx";
const postmx = new PostMX(Cypress.env("POSTMX_API_KEY"));
it("logs in with a magic link", () => {
cy.then(() => postmx.createTemporaryInbox({ label: "cypress-magic-link" }))
.then((inbox) => {
cy.visit("/login");
cy.get('input[type="email"]').type(inbox.email_address);
cy.contains("Send link").click();
return cy.then(() => postmx.waitForMessage(inbox.id))
.then((email) => {
expect(email.links[0]?.url).to.be.ok;
cy.visit(email.links[0].url);
});
});
});
Related links
These pages cover the adjacent flows that usually sit next to magic links in a real product.
A shorter product overview for teams that want the workflow in one screen.
Open pageSee the adjacent flow for verification codes when the passwordless login path becomes a one-time code.
Open pageRead the broader onboarding guide if you want to understand the product from the first import onward.
Open articleStart building today
Capture the link from the email your app actually sent, then continue the test with the URL the user would click.