I was going to talk about Cypress but then I started an internship and I’ve been building an API in Next.js.

Since I’m excited about testing right now, I wanted to write automated tests for my API.

The more your tests resemble the way your software is used, the more confidence they can give you.

I still wanted to stick with this idea. The ideal way to test this would be through the frontend, with Cypress or Jest and React-Testing-Library. However, the frontend build was in process. So, that wouldn’t work.

I needed to test the backend from the backend.

Postman

Postman seemed like an obvious first choice.

The biggest initial challenge was that the API is secured with NextAuth. I could disable the authentication for the purpose of testing but that felt like a short term solution.

Luckily for me, someone had documented how to use Postman to authenticate with NextAuth.

https://github.com/nextauthjs/next-auth/discussions/1208#top