Parallel email testing: give every test its own inbox
Prevent cross-test email mix-ups with dedicated Agent Temp Mail identities, bounded polling, and clear message matching in parallel test suites.
On this page
Parallel tests become difficult to trust when they all read the same mailbox. One worker can pick up another worker's verification code, a retry can find an earlier message, and deleting mail can break a neighboring test. Agent Temp Mail's key-derived addresses offer a practical way to avoid that shared state: generate a separate identity for each independent scenario.
Choose the right identity boundary
For an independent signup test, use a new identity for every test attempt. A retry then gets a different inbox and cannot accidentally consume mail from its failed predecessor. Keep the identity in the test fixture rather than in a shared global variable.
For a scenario with several dependent steps, reuse that scenario's identity. Signup, account verification, and password recovery need to refer to the same account address. Isolation means separating independent scenarios, while preserving continuity inside a scenario.
Create the inbox identity locally
Agent Temp Mail derives an address from a cryptographic keypair. Its SDK provides generateIdentity() and MailClient, so a test can establish its receiving identity in setup and use the client's address in the application form. This avoids coordinating a shared pool of manually assigned inbox names.
Keep each private key within the process or protected fixture storage that needs it. Addresses can appear in diagnostic output when appropriate; private keys should not. If a test spans multiple processes, pass the identity through your existing protected credential mechanism instead of a public build artifact.
Match messages within the isolated inbox
A dedicated inbox removes cross-test collisions, but a single scenario may still receive several emails. Record the time before each action and filter for the expected sender and newly received messages. Inspect the subject or expected link path when signup and recovery messages use the same sender.
Track message IDs already handled by the scenario. This makes repeated polling easier to reason about and avoids treating the same email as a new event. Bound the overall wait, respect the service's polling guidance, and report a timeout with the failed stage.
Scale with a controlled concurrency budget
Separate identities do not remove delivery delays, application throttles, or service limits. Set test-runner concurrency to a level your application and mail delivery provider can support. When a suite starts timing out, distinguish missing outgoing mail from slow delivery or a message-matching mistake before increasing timeouts.
Agent Temp Mail makes inbox ownership explicit at the test level. The result is a simpler failure model: each scenario owns its address, its messages, and its assertions. That is a useful foundation for running real email flows alongside the rest of a parallel CI suite.