Skip to main content
Below is a basic guide on setting up E2E testing with NextJS, Resend, and Playwright. Prefer watching a video? Check out our video walkthrough below.

Guide

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 at 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
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 files
  • outputDir: the directory to store test results
  • webServer: provide instructions for Playwright to run your app before starting the tests
  • projects: an array of the browsers you want to test
playwright.config.ts
See the Playwright docs for more help.
4

Run the test

You can run the test by installing Playwright and running the tests.
Playwright will run the tests in the browsers of your choice and show you the results.

Examples

Example repo

See the full source code.