StoicBuilder

HandbookVIII the PalaestraEnd-to-end tests

VIIIthe Palaestra, Test it

End-to-end tests

1 min readUpdated 28 November

In plain words

An end-to-end test drives a real browser through a complete task, such as signing up and choosing a plan, and checks what the user would see at each step.

Where you see it

Playwright opens Harbor's sign-up page, fills in an email, picks the Pro plan, pays with Stripe's test card 4242 4242 4242 4242 and checks that the dashboard says Pro. It can run the same steps in Chromium, Firefox and WebKit before each release.

e2e/signup.spec.tsbrowser
import { test, expect } from "@playwright/test"; test("a new team can sign up on the Pro plan", async ({ page }) => { await page.goto("/signup"); await page.getByLabel("Work email").fill("e2e+pro@example.com"); await page.getByRole("button", { name: "Choose Pro" }).click(); await expect(page.getByText("Plan: Pro")).toBeVisible();});
Locators by label and role find elements the way a person would, and expect keeps checking until the text appears or time runs out.

What goes wrong

  1. Testing everything end to end

    These tests are slow and can break for many reasons. Keep a handful for the paths that make money or lock people out, such as sign-up, login, upgrade and cancel, and test the details lower down.

  2. Finding elements by CSS class

    A redesign renames a class and twenty tests fail while the app works fine. Find elements by role, label or visible text, or by a data-testid you add on purpose.

    await page.click(".sc-1x7d .btn-primary-2");
  3. Running against live data

    A sign-up test pointed at the live site creates real accounts and real Stripe customers. Run it against a preview or staging environment with test keys, and give test accounts an address you can find and clear later.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Write Playwright tests for Harbor's three most important paths: sign up, upgrade to Pro, and invite a teammate. Find elements by role, label or text rather than CSS classes, run them against the staging URL with Stripe test keys, and show me the report.

Quick check

Sign in to earn +10 XP for it

Harbor has 400 unit tests and no end-to-end tests. Where should the first Playwright test go?

Got a prompt that touches End-to-end tests?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.