I am starting to do e2e tests with playwright. Most of the application requires to be authenticated. Automating this with a username/password mechanism is quite easy. The problem is that the app I want to test has only two authentication mechanisms: Github OAuth and email authentication links. Specifically I am using next-auth in a NextJS project.
I don't know how should I e2e test this with Playwright, the options I have considered are:
- Completly mocking the authentication using a mock user and a mock session and then append the session token in the test context (as it is described here in the official docs).
- Creating a Github user and/or an email account for the tests and somehow truly use them in playwrigth.
The first option is much easier to implement but then it's not e2e testing anymore. The second option looks difficult to implement and I don't know if it is recommended. I don't know if there are smarter or more standarized ways to proceed with this.