1. 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
2. Write the test spec file
Create a test spec file ate2e/app.spec.ts
. You can test in two ways:
Option 1: Call the Resend API
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
Option 2: Mock a response
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
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.
3. Create a Playwright config file
Write your config file, paying special attention to a few properties: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
4. Run the test
You can run the test by installing Playwright and running the tests.Example repo
See the full source code.