Mock auth0 login and MFA flow for E2E testing using Playwright

Problem:
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.

Context:
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.

Attempts:
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.

Request:
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.

Environment:

  • 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!

3 Likes

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.

2 Likes

Up!

I am facing the exact same issue :smiling_face_with_tear:

1 Like

I have similar issue, let me kow if you got any solution to bypass MFA for automation testing