Testing guide
Test magic-link login emails without a shared mailbox
A magic-link test crosses two systems: the browser starts authentication and email delivers the credential. PNTR gives the test a unique recipient and a direct API path to the message without automating a consumer mailbox.
Explore PNTR's disposable email for developersValidate an extracted link
const match = message.body_text?.match(
/https:\/\/staging\.example\.com\/auth\/verify\?[^\s]+/
);
if (!match) throw new Error("Magic link not found");
const magicLink = new URL(match[0]);
if (magicLink.origin !== "https://staging.example.com") {
throw new Error("Unexpected magic-link origin");
}
await page.goto(magicLink.toString());Setup
- 1
Use a dedicated test inbox
Create an email-enabled PNTR subdomain, store its ID and API token as test secrets, and restrict this workflow to a non-production application environment.
- 2
Start with a unique address
Generate a recipient such as [email protected] and enter it in the application's passwordless login form. Record the request start time.
- 3
Find the correct message
Poll PNTR until an email matches the full recipient and was received after the request began. Fetch that message by ID to read its text or sanitized HTML body.
- 4
Validate the URL before opening it
Extract the URL using your template's known prefix, parse it, and assert the protocol and hostname belong to the test application. Do not navigate to an arbitrary link found in email content.
- 5
Test success, replay, and expiry
Open the link in the intended browser context and assert the authenticated result. Separately verify that the link is single-use and expires according to your application's documented behavior.
Before you ship
A magic link is a temporary credential. Keep PNTR API tokens and captured messages out of test logs, use synthetic accounts, and assert the destination origin before the browser follows the link.