How to Manage Authentication & State in Your End-to-End Tests with Playwright

Three approaches to working with state data in your Playwright end-to-end tests

Marco Lüthy
7 min readSep 30, 2021
Cover photo of a lady bug close up
Bugs. They’re what we’re trying to avoid with our E2E tests. Photo by Dustin Humes. Thank you, Dustin!

Playwright is an open source tool by Microsoft for browser automation and end-to-end testing. Playwright can drive Chromium (Chrome), WebKit (Safari) and Firefox in both headed and headless modes (with and without windows on the screen.) And, it comes with some pretty cool and powerful development and debugging tools that are quick and easy to use.

End-to-end (E2E) tests are not-really-unit tests in which real browsers are used to interact with a website or web app to check if things are working as expected. They’re commonly used to ensure that often-used UX/UI workflows like login pages or other app interactions are working correctly, often when it becomes too cumbersome to manually test everything in a SaaS product.

This article is Part 3 in a series of articles aimed at getting you started with everything you need to write end-to-end (E2E) tests using Playwright. In this article, we’ll look at how to work with authentication and other browser state across your E2E tests. I’ll assume that you’ve read Part 1 of the series.

Articles in this series

  1. How to Write

--

--

Marco Lüthy
Marco Lüthy

Written by Marco Lüthy

Hi there! I’m Marco. I write mostly about software development, sometimes about books I’ve read, and occasionally something else to keep things interesting.

No responses yet