Guide
Create an endpoint
For simplicity, we’ll create a GET endpoint that sends an email to the testing account,
delivered@resend.dev on fetch.app/api/send/route.ts
Write the test spec file
Create a test spec file at Mocking the response lets you test your app’s flow without calling the Resend API and impacting your account’s sending quota.
e2e/app.spec.ts. You can test in two ways: by calling the Resend API or by mocking a response.Calling the Resend API tests the entire API flow, including Resend’s API responses, but counts towards your account’s sending quota.e2e/app.spec.ts
e2e/app.spec.ts
However you test, it’s important to test using a test email address (e.g.,
delivered@resend.dev) so your tests don’t impact your deliverability. Resend’s
test accounts run through the entire API
flow without harming your reputation.
Create a Playwright config file
Write your config file, paying special attention to a few properties:See the Playwright docs for more help.
testDir: the directory containing your test filesoutputDir: the directory to store test resultswebServer: provide instructions for Playwright to run your app before starting the testsprojects: an array of the browsers you want to test
playwright.config.ts
Examples
Example repo
See the full source code.