E2E Mailbox is a fully-typed TypeScript library designed for integrating email notification testing into end-to-end test suites. It enables developers to programmatically create temporary email addresses, wait for specific emails to arrive based on subject lines, and extract content like URLs or pins from email bodies for verification. The library currently leverages free, third-party services—DeveloperMail and GuerrillaMail—offering an automatic fallback mechanism to enhance reliability. Key use cases include verifying account registration emails, password reset flows, and ensuring correct email content after specific user actions within an application. It is currently at version 1.1.7 and appears to be actively maintained, providing a robust solution for automating tests that rely on email communication without manual intervention. Its primary differentiator is its focus on e2e testing with a resilient, multi-provider approach to temporary email addresses.
npm install e2e-mailboxVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the core functionality of E2E Mailbox: creating a temporary email address, polling for an email by its subject line, extracting links from the email body, and finally deleting the email for cleanup. It simulates a common E2E testing scenario for email-dependent features like user registration and account confirmation.
Implement robust retry mechanisms in your tests. Monitor the status of DeveloperMail and GuerrillaMail. For critical applications, consider using a self-hosted email testing solution or a paid service with dedicated APIs and SLAs.
Increase the `timeoutInSeconds` parameter for `mailbox.waitForEmail()` if tests are consistently failing due to emails not being found. Add a small, fixed delay before initiating `waitForEmail()` to give the email system a head start.
Ensure the email templates used by your application are stable. For critical links (e.g., confirmation links), consider designing the email content to embed unique identifiers or specific patterns that make extraction more robust than generic link parsing. Test `extractLinksFromEmail` against various email templates.
Verify that your application is indeed sending the email to the generated address. Double-check the exact subject line for any typos or leading/trailing spaces. Increase the `timeoutInSeconds` parameter in `mailbox.waitForEmail()` to allow more time for delivery.
Always add a null-check after `await mailbox.waitForEmail()` to ensure an email object was successfully returned before attempting to process it. For example: `const foundEmail = await mailbox.waitForEmail(...); if (foundEmail) { ... } else { console.error('Email not found!'); }`Introduce delays between your E2E tests that perform email operations. Restructure your test suite to reuse email addresses for multiple tests where possible, or reduce the number of parallel tests that heavily rely on email generation and polling.
No dependency data recorded yet.