Testing Authentication
Many web applications will involve authenticating users. This chapter shows how you can write tests for this functionality. These tests cover logging in, logging out, and ensuring that your application is only accessible to logged-in users.
This chapter is not a walkthrough and only includes a small amount of detail on the application code required to implement authentication. The book repository uses the Auth.js library, but the same testing techniques will work regardless of the implementation approach.
The chapter covers the following key topics:
- Testing authentication with Playwright
- Testing authentication with Vitest
By the end of the chapter, you’ll have seen how to write tests that cover all aspects of authentication.