Member-only story

Hidden Goodies in Playwright That Will Super-Charge Your End-to-End Testing Experience

Exposing some of the goodies hidden in the Playwright documentation

--

Cover photo of lady bugs hidden between leaves
Bugs. They’re what we’re trying to avoid with our E2E tests. Photo by Daniel Cooke. Thank you, Daniel!

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 4 in a series of articles aimed at getting you started with everything you need to write end-to-end (E2E) tests using Playwright. This final article covers some additional goodies or features Playwright ships with which haven’t already been covered.

Articles in this series

  1. How to Write End-to-End Tests for Chrome, Safari & Firefox Using Playwright
  2. Playwright Comes with Amazing Tools for Writing and Debugging Your End-to-End Tests
  3. How to Manage Authentication & State in Your End-to-End Tests with Playwright
  4. Hidden Goodies in Playwright That Will Super-Charge Your End-to-End Testing Experience

Test Sharding

As your end-to-end test suite begins to grow with tests covering more and more of your web app, it’ll take longer and longer for all of your tests to pass. There are a few ways to speed things up (like, do you really need an E2E test for all those things?) One way is to split up your tests and run them across multiple machines (or job workers on CI). Playwright supports this out-of-the-box with test sharding.

npx playwright test --shard=1/3
npx playwright test --shard=2/3
npx playwright test --shard=3/3

--

--

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

Write a response