Testing authentication with Playwright
This section details the groundwork required for effective testing with your Playwright tests. First, we look at how to provide hard-coded authentication credentials for your end-to-end tests. Then we use this to verify that users can log in and log out of the application. Finally, we’ll update the existing tests so that they ensure the user is logged in before attempting to test the application functionality.
What about Cucumber?
If you’re using Cucumber tests with Playwright, then the same techniques presented here will also work for you.
Creating an auth profile for dev and test modes
It’s fairly typical to use OAuth authentication strategies that delegate authentication responsibilities to a third-party provider, such as Google or GitHub. However, when it comes to writing end-to-end tests, it’s impractical to maintain user accounts with these third parties just for the purposes of testing. For one thing...