@qawolf/emails
v1.0.0
Published
`@qawolf/emails` is a TypeScript toolkit designed to help you use QA Wolf-managed inboxes in email-driven tests.
Keywords
Readme
@qawolf/emails
@qawolf/emails is a TypeScript toolkit designed to help you use QA
Wolf-managed inboxes in email-driven tests.
The QA Wolf runner configures the emails client for each flow, so flow code can
call mail.inbox() directly. Use it to create inbox addresses, wait for
inbound messages, parse links from email content, and send outbound messages.
To learn more about how to use @qawolf/emails, check out the
API Reference
and Documentation.
Install
npm install @qawolf/emailsUsage
Create a fresh inbox for the current run, trigger an email in your app, and continue with the message QA Wolf receives.
import { mail } from "@qawolf/emails";
const inbox = await mail.inbox({ new: true });
await page.getByLabel("Email").fill(inbox.emailAddress);
const after = new Date();
await page.getByRole("button", { name: "Send magic link" }).click();
const message = await inbox.waitForMessage({ after });
const signInUrl = message.urls[0];Pass new: true for most tests. It creates a unique derived address so emails
from earlier runs do not affect the current flow. If your app does not support
plus addresses, pass a custom delimiter.
const inbox = await mail.inbox({ new: true, delimiter: "-" });Capture after immediately before the app action that should send email. This
keeps waitForMessage(...) pinned to the message caused by that action.
Send email from the same inbox when your workflow needs an inbound message or reply.
await inbox.sendMessage({
to: ["[email protected]"],
subject: "Test message",
text: "Hello from a QA Wolf flow",
});For runners and local harnesses, create and configure a client before invoking flow code.
import { configureEmailsClient, createEmailsClient } from "@qawolf/emails";
const emails = await createEmailsClient({
emailerUrl: process.env["EMAILER_URL"]!,
pollForEmailsDefaultTimeoutMs: 300_000,
teamId: process.env["QAWOLF_TEAM_ID"],
waitForMessagesDefaultDelayMs: 15_000,
});
configureEmailsClient(emails);