Mock auth0 login and MFA flow for E2E testing using Playwright

I’m currently facing challenges with mocking the login and multi-factor authentication (MFA) flow when using the nextjs-auth0 for authentication in my Next.js application.

I’m using Playwright for end-to-end (E2E) testing of my Next.js application. However, I’m struggling to effectively mock the login process and bypass the MFA flow during testing.

I’ve tried several approaches, including intercepting network requests to simulate the authentication process and manually mocking the auth0 login. However, none of these solutions have provided satisfactory results.

I would greatly appreciate any guidance or suggestions on how to effectively mock the login and MFA flow with nextjs-auth0 SDK for authentication in a Next.js application. Specifically, I’m looking for a solution that allows me to bypass the authentication flow during testing to streamline the testing process.


  • Next.js version: 14.1.0
  • @auth0/nextjs-auth0 version: 3.3.0
  • Playwright version: 1.43.0
  • Node.js version: 20

Additional Information:
Please let me know if any additional details or context would help address this issue.

Thank you for your assistance!

1 Like

Hello Tanisha, have you found a solution ? . I am also facing the problem you have mentioned.
Have to test the web applciation with playwright for E2E and the application uses auth0 for login.