GuidesEnd-to-end testing
Your first 10 tests
Expand from one flow to 10 core tests across your product domains, spot overlapping setup early, and start creating users programmatically.
In Set up a Playwright suite, you got one flow you would be embarrassed to break running on every pull request. That proves the setup works and protects one critical path, but it still leaves most of your product unchecked.
Going from 1 test to 10 is how you build real baseline confidence across the main parts of your app. You need a working Playwright suite running on Endform (using Playwright Intent or plain Playwright). You can follow along on your own app or inspect the complete BikeBook suite in suites/02-first-10-tests.
This guide takes you from 10 tests that each sign up through the UI to 10 tests that start from a programmatic user:
- Setup in the UI
- Setup via API
- Flow under test
64% of test time is setup · illustrative timings
Pick 10 flows across your core domains
Rather than walking through routes one by one, divide your product into three or four core domains and list the two to four flows in each domain that users rely on every day.
In BikeBook, an office bike-booking app, the product splits cleanly into three domains:
- Sign up and land on the dashboard
- Sign in and sign out from the user menu
- Delete an account and confirm it can no longer sign back in
- Invite a teammate who joins and books a bike
- Add bikes and list them with their type
- Remove a bike and clear its bookings
- Reject duplicate bike names when adding a bike
- Book a bike and see it in upcoming bookings and activity
- Cancel a booking to free the slot
- Block double-booking when two browsers pick the same slot
Every product's domains look different, but the shape is similar. An e-commerce app might split into catalog and search, cart and checkout, and account and orders. Aim for 8 to 10 flows that cover the core promise of your product plus a couple of important error cases.
Spot the overlap before writing all 10
Start by writing the first three tests, one from each domain. Here is the bookability one, which books a bike for next week. Hover or click an ai.do(...) line to inspect its compiled Playwright code:
import { expect, test } from "playwright-intent"; test("users can book a bike and see it in their upcoming bookings", async ({ page, ai,}) => { const email = `user-${Date.now()}-${Math.random().toString(36).slice(2, 8)}@example.com`; await page.goto("/sign-up"); await page.goto(`/dashboard?date=${nextWeek()}`); await expect(page.getByRole("status")).toContainText("Booked Road 1"); await expect(page.getByRole("row", { name: /Road 1/ })).toContainText( "Booked by you", ); await expect( page.getByRole("listitem").filter({ hasText: "Road 1" }), ).toContainText("morning"); await page.getByRole("link", { name: "Activity" }).click(); await expect(page.getByText(/You booked Road 1/)).toBeVisible();}); function nextWeek() { const day = new Date(); day.setUTCDate(day.getUTCDate() + 7); return day.toISOString().slice(0, 10);}The fleet and user management tests start the same way. All three sign up a new user through /sign-up before they ever reach the feature they are meant to check.
If you keep going and write all 10 tests that way, your suite ends up looking like this:


Repeating sign-up in every test causes two problems right away:
- You spend a third to almost half of your test time signing users in. Every test pays the full cost of loading
/sign-up, filling the form, and waiting for redirects before doing the work you actually wrote it for. - Failures stop telling you what broke. If the sign-up form changes or breaks, tests in fleet management and bookability go red even though booking and fleet management still work. Earlier setup failures hide the signal you want from the rest of the suite.
Scaling from 1 test to 10 is mostly about noticing where your flows overlap and removing the biggest shared setup early. In almost every web app, the first overlap worth removing is creating a signed-in user.
Start non-auth tests from a programmatic user
Keep dedicated tests that drive your real sign-up and sign-in UI so you still have full confidence in authentication. In BikeBook, the two auth tests in tests/users.spec.ts run through /sign-up, /sign-in, and sign-out by themselves.
For the other eight tests (account deletion, team invites, fleet management, and bookability), skip the sign-up form entirely: create a fresh, isolated user through an internal test endpoint, set their session cookie on the browser context, and delete the user when the test finishes.
In BikeBook, a small extended fixture in tests/test-with-new-user.ts exports testWithNewUser, which creates a fresh signed-in user before each test and cleans it up afterwards:
import { test as base } from "playwright-intent";
export const testWithNewUser = base.extend<{ newUser: User }>({
newUser: [
async ({ request, context, baseURL }, use) => {
const user = await createUser(request);
await context.addCookies([
sessionCookie(user.session, baseURL as string),
]);
await use(user);
await deleteUser(request, user.email);
},
{ auto: true },
],
});In BikeBook, it is one small route, app/api/internal/user/route.ts, that only accepts requests with a shared bearer token:
POST /api/internal/userwith{ email, password }signs the user up through the same code the sign-up form uses, creates a session, and returns it as{ session }.DELETE /api/internal/userwith{ email }deletes the user and their team membership.
The fixture puts the returned session in the browser's session cookie, so every page loads as that user. If your app uses an auth provider such as Clerk, Auth0, or Supabase, its admin API can usually create test users for you instead.
Playwright's authentication guide often uses a setup project that signs in once and saves storageState so every test shares the same account. That avoids building an internal test endpoint and works well when your tests only read data.
In BikeBook, all eight non-auth tests write data (deleting accounts, inviting teammates, adding or removing bikes, booking and cancelling slots). If they shared one account in parallel, they would delete or overwrite each other's state and start flaking immediately. Giving each test its own user through testWithNewUser keeps every test isolated and avoids a sequential setup step before parallel runs can start.
Here is the same booking test written with testWithNewUser. The sign-up step is gone, and the test starts on the dashboard as a signed-in user:
import { expect, testWithNewUser } from "./test-with-new-user"; testWithNewUser( "users can book a bike and see it in their upcoming bookings", async ({ page, ai }) => { await page.goto(`/dashboard?date=${nextWeek()}`); await expect(page.getByRole("status")).toContainText("Booked Road 1"); await expect(page.getByRole("row", { name: /Road 1/ })).toContainText( "Booked by you", ); await expect( page.getByRole("listitem").filter({ hasText: "Road 1" }), ).toContainText("morning"); await page.getByRole("link", { name: "Activity" }).click(); await expect(page.getByText(/You booked Road 1/)).toBeVisible(); },); function nextWeek() { const day = new Date(); day.setUTCDate(day.getUTCDate() + 7); return day.toISOString().slice(0, 10);}Now the suite looks very different. Two tests still exercise authentication through the UI, while the other eight start straight from a signed-in user and spend almost all of their time testing the actual behavior they are named after:


Click any file below to inspect the full 10-test suite in BikeBook:
import type { APIRequestContext } from "@playwright/test";import { test as base } from "playwright-intent"; export const PASSWORD = "testpassword123"; // Internal test endpoint disabled in production and gated behind a shared token.const INTERNAL_API_HEADERS = { authorization: "Bearer VerySecretDummyToken" }; export type User = { email: string; password: string; session: string }; export const testWithNewUser = base.extend<{ newUser: User }>({ newUser: [ async ({ request, context, baseURL }, use) => { const user = await createUser(request); await context.addCookies([ sessionCookie(user.session, baseURL as string), ]); await use(user); await deleteUser(request, user.email); }, { auto: true }, ],}); export { expect } from "@playwright/test"; export function uniqueEmail(prefix = "user") { return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}@example.com`;} async function createUser( request: APIRequestContext, email = uniqueEmail(),): Promise<User> { const response = await request.post("/api/internal/user", { headers: INTERNAL_API_HEADERS, data: { email, password: PASSWORD }, }); if (!response.ok()) { throw new Error( `Creating ${email} failed (${response.status()}): ${await response.text()}`, ); } const { session } = await response.json(); return { email, password: PASSWORD, session };} async function deleteUser(request: APIRequestContext, email: string) { await request.delete("/api/internal/user", { headers: INTERNAL_API_HEADERS, data: { email }, });} function sessionCookie(session: string, baseURL: string) { return { name: "session", value: session, domain: new URL(baseURL).hostname, path: "/", expires: -1, httpOnly: true, secure: true, sameSite: "Lax" as const, };}import { test } from "playwright-intent";import { expect, PASSWORD, testWithNewUser, uniqueEmail,} from "./test-with-new-user"; test("new visitors can sign up and land on their office's bikes", async ({ page, ai,}) => { await page.goto("/sign-up"); await ai.do("sign up with email {email} and password {password}", { email: uniqueEmail(), password: PASSWORD, }); await expect(page).toHaveURL("/dashboard"); await expect(page.getByRole("heading", { name: "Bikes" })).toBeVisible(); await expect(page.getByText("Your office has no bikes yet.")).toBeVisible();}); test("users can sign in and sign out", async ({ page, ai }) => { const email = uniqueEmail(); await page.goto("/sign-up"); await ai.do("sign up with email {email} and password {password}", { email, password: PASSWORD, }); await ai.do("sign out from the user menu"); await expect(page.getByRole("link", { name: "Sign Up" })).toBeVisible(); await page.goto("/sign-in"); await ai.do("sign in with email {email} and password {password}", { email, password: PASSWORD, }); await expect(page).toHaveURL("/dashboard"); await expect(page.getByRole("heading", { name: "Bikes" })).toBeVisible();}); testWithNewUser( "deleting an account signs the user out and blocks signing back in", async ({ page, newUser, ai }) => { await page.goto("/dashboard/security"); await page .getByRole("textbox", { name: "Confirm Password" }) .fill(newUser.password); await page.getByRole("button", { name: "Delete Account" }).click(); await expect(page).toHaveURL("/sign-in"); await ai.do("sign in with email {email} and password {password}", { email: newUser.email, password: newUser.password, }); await expect( page.getByText("Invalid email or password. Please try again."), ).toBeVisible(); },); testWithNewUser( "an invited teammate can join the team and book a bike", async ({ page, ai }) => { const teammateEmail = uniqueEmail("teammate"); await page.goto("/dashboard"); await ai.do("add a city bike named City 1 to the fleet"); await page.getByRole("link", { name: "Team" }).click(); await ai.do("invite {email} to the team as a member", { email: teammateEmail, }); const inviteHref = await page .getByRole("link", { name: /inviteId=/ }) .getAttribute("href"); expect(inviteHref).toMatch(/^\/sign-up\?inviteId=\d+$/); await ai.do("sign out from the user menu"); await page.goto(inviteHref as string); await ai.do( "accept the invitation and sign up with email {email} and password {password}", { email: teammateEmail, password: PASSWORD }, ); await page.goto(`/dashboard?date=${nextWeek()}`); await page.getByRole("button", { name: "Book City 1 morning" }).click(); await expect(page.getByRole("status")).toContainText("Booked City 1"); },); function nextWeek() { const day = new Date(); day.setUTCDate(day.getUTCDate() + 7); return day.toISOString().slice(0, 10);}import { expect, testWithNewUser } from "./test-with-new-user"; testWithNewUser( "owners can add bikes and see them listed with their type", async ({ page, ai }) => { await page.goto("/dashboard"); await ai.do("add a road bike named Road 1 to the fleet"); await ai.do("add a cargo bike named Cargo to the fleet"); const rows = page.getByRole("row"); await expect(rows).toHaveCount(3); await expect(rows.nth(1)).toContainText("Road 1"); await expect(rows.nth(1)).toContainText("Road bike"); await expect(rows.nth(2)).toContainText("Cargo"); await expect(rows.nth(2)).toContainText("Cargo bike"); },); testWithNewUser( "removing a bike removes it and its bookings", async ({ page, ai }) => { await page.goto(`/dashboard?date=${nextWeek()}`); await ai.do("add a cargo bike named Cargo to the fleet"); await page.getByRole("button", { name: "Book Cargo morning" }).click(); await expect(page.getByRole("status")).toContainText("Booked Cargo"); await page.getByRole("button", { name: "Remove Cargo" }).click(); await expect( page.getByRole("rowheader", { name: "Cargo", exact: true }), ).toHaveCount(0); await expect(page.getByText("No upcoming bookings.")).toBeVisible(); },); testWithNewUser("duplicate bike names are rejected", async ({ page, ai }) => { await page.goto("/dashboard"); await ai.do("add a road bike named Road 1 to the fleet"); await page.getByRole("textbox", { name: "Bike name" }).fill("Road 1"); await page.getByRole("button", { name: "Add bike" }).click(); await expect( page.getByText("A bike named Road 1 is already in your fleet"), ).toBeVisible();}); function nextWeek() { const day = new Date(); day.setUTCDate(day.getUTCDate() + 7); return day.toISOString().slice(0, 10);}import { expect, testWithNewUser } from "./test-with-new-user"; testWithNewUser( "users can book a bike and see it in their upcoming bookings", async ({ page, ai }) => { await page.goto(`/dashboard?date=${nextWeek()}`); await ai.do("add a road bike named Road 1 to the fleet"); await ai.do("book Road 1 for the morning"); await expect(page.getByRole("status")).toContainText("Booked Road 1"); await expect(page.getByRole("row", { name: /Road 1/ })).toContainText( "Booked by you", ); await expect( page.getByRole("listitem").filter({ hasText: "Road 1" }), ).toContainText("morning"); await page.getByRole("link", { name: "Activity" }).click(); await expect(page.getByText(/You booked Road 1/)).toBeVisible(); },); testWithNewUser( "cancelling a booking frees the slot again", async ({ page, ai }) => { await page.goto(`/dashboard?date=${nextWeek()}`); await ai.do("add a cargo bike named Cargo to the fleet"); await page.getByRole("button", { name: "Book Cargo afternoon" }).click(); await expect(page.getByRole("status")).toContainText("Booked Cargo"); await page.getByRole("button", { name: "Cancel Cargo afternoon" }).click(); await expect(page.getByRole("status")).toContainText("Cancelled Cargo"); await expect( page.getByRole("button", { name: "Book Cargo afternoon" }), ).toBeVisible(); await expect(page.getByText("No upcoming bookings.")).toBeVisible(); },); testWithNewUser( "a bike can't be booked twice for the same slot", async ({ page, ai, browser }) => { const day = `/dashboard?date=${nextWeek()}`; await page.goto(day); await ai.do("add a road bike named Road 1 to the fleet"); const otherContext = await browser.newContext({ storageState: await page.context().storageState(), }); const otherPage = await otherContext.newPage(); await otherPage.goto(day); await page.getByRole("button", { name: "Book Road 1 morning" }).click(); await expect(page.getByRole("status")).toContainText("Booked Road 1"); await otherPage .getByRole("button", { name: "Book Road 1 morning" }) .click(); await expect( otherPage.getByText(/Road 1, .+ is already booked/), ).toBeVisible(); await otherContext.close(); },); function nextWeek() { const day = new Date(); day.setUTCDate(day.getUTCDate() + 7); return day.toISOString().slice(0, 10);}Run all 10 tests on Endform
Run the suite on Endform with each test repeated three times, which checks that no test depends on the order or data of another:
npx endform@latest test --repeat-each=3All 30 runs should pass. Because each test creates and cleans up its own user, they run in parallel across separate machines without colliding. On your first run with new ai.do(...) steps, Playwright Intent generates the .intent/ TypeScript files; commit them alongside your tests so pull-request checks replay with zero model calls.
Here is today's scheduled run of these 10 tests in Endform:
What still overlaps
Most of the eight tests that start from testWithNewUser still add a bike through the Manage fleet UI before booking or removing it. At 10 tests, that is fast and keeps the setup simple. Once your suite grows past 20 tests, apply the same programmatic setup to domain data, like seeding a fleet, and pair it with a flake routine. Both are covered in From 10 to 100 tests.
Last updated