Kunal Ukey
Kunal Ukey

Reputation: 320

How to mock the session object to the route api/auth/session in NextAuth in a new Next.js 13 app directory in my Cypress test?

I am currently using the new Next.js 13 app directory and next-auth for authentication. The session is generated server-side, so I can't access the session object in Cypress. I want to mock the session object in Cypress so that I can test my application's functionality without having to be logged in.

I have tried the following to mock the session object:

Here are some additional details about my environment:

Upvotes: 1

Views: 2249

Answers (1)

Augusto Oliveira
Augusto Oliveira

Reputation: 127

I suggest you to take a look at msw. I use it a lot in every project.

https://mswjs.io/

Upvotes: 0

Related Questions