14

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

Get Svelte with Test-Driven Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.