Challenge: Test API Routes with Cypress
Challenge yourself by manually testing API routes and asserting the correct responses.
We'll cover the following...
Although the process of testing API routes is similar to testing other pages, there are a few differences to consider. For instance, when testing the creation of meetups, instead of manually filling up a form and submitting it, we can directly call the API route responsible for creating new meetups. Since we use trpc
to handle our API routes, determining the correct path for the API route is not as straightforward.
Based on the file structure, we can see that this file is located at /pages/api/trpc/[trpc].ts
. The API route for this file is /api/trpc/[trpc]
, where [trpc]
represents the name of our mutation, which, in this case, is create
. ...