Email verification tests tend to become unreliable for a reason that is easy to miss: the inbox is shared state. One test creates an account, another test reads its message, and a retry may find an old verification link instead of the one it expected.
I have had better results by treating every test inbox and verification record as a run-scoped fixture. The fixture gets an owner, an expiry time, and a correlation ID. PostgreSQL stores the relationship, while the test client uses the correlation ID to ask the REST API for exactly one expected result.
This approach works whether the test system creates mailboxes internally or uses a controlled free throwaway email provider in staging. Isolation belongs in our application and test design.
Why email fixtures need a scope
A test that searches an inbox for “verification” is asking a vague question. It may match a message from a previous run, a parallel test, or a user who happens to share the same fixture address.…