Get your API key

Lesson 4 of 5

End-to-end tests with Playwright

A robot browser clicks through your app's main journeys. Set up Playwright, record a journey, and read the UI mode and HTML report.

9 min Log in to open
One step at a time, like flipping pages.

By the end of this lesson a robot browser will click through your app's most important journeys after every change, and you will be able to watch it, read its report and spot where it failed.

You need: your project with Vitest from Lesson 3, Node.js 22 or newer, Windows 11 or macOS 14 or newer, about 1 GB of free disk space for the test browsers · Time: 9 minutes

  1. Unit tests check rules. An end-to-end test checks a whole journey: what a real person does from start to finish, in a real browser. Playwright is a free tool from Microsoft that opens a browser, clicks, types and checks what appears, much faster than you.

    Do not test everything this way. Pick the 3 to 5 journeys that would hurt most if they broke. For Sharma Coaching:

    1. Log in as the admin.
    2. Find a student and mark this month's fee as paid.
    3. Download the monthly fee list as CSV.

    Write each journey as steps a person would do, ending with what they must see:

    Put in order

    Put the "mark fee as paid" journey in the right order

    Tap the steps in the order you would do them. Tap a placed step to remove it.

    1. 1
    Why?

    End-to-end tests are slower and need more care than unit tests, so spend them only where a break would cost money or trust: logins, payments, and the main daily task.

Log in free to read the rest of this lesson

Every lesson is free. A free account unlocks all of them and saves your progress.

Still to come in this lesson:

  1. Let the agent install Playwright
  2. Record a journey by clicking
  3. Run it and watch it
  4. Read the report when it fails
  5. Recap