GuidesEnd-to-end testing
From 10 to 100 tests
Scale a Playwright suite past 20 tests by expanding programmatic scenario data, running a weekly flake routine, and keeping parallel runs fast.
In Your first 10 tests, you mapped your core product domains and removed the biggest universal overlap by creating users programmatically. Writing test #11 is not what slows teams down next.
Suites usually grow from 10 tests to 100 organically, as new features ship and production bugs become regression tests. Along the way, most suites stall around 20 tests unless you solve three scaling problems:
- Test data outgrows a single user. Signing in programmatically is enough for 10 tests, but deeper flows need seeded domain data, empty states, and multiple roles without parallel tests overwriting each other.
- Flakes compound and erode trust. A small per-test flake rate that looks manageable at 10 tests turns pull requests red regularly at 100 tests, even with retries on, and engineers stop trusting the suite.
- Slow outliers drag down every run. Without isolated, focused tests, wall-clock time creeps up until nobody wants to wait for the suite on pull requests.
You can inspect the full 103-test BikeBook suite behind this guide in suites/03-scaled-suite.
Creating test data through the API removes the setup that still overlaps at 10 tests. In that suite, every signed-in test starts from a new user and adds only the bikes or teammate it needs:
- Setup in the UI
- Setup via API
- Flow under test
48% of test time is setup · illustrative timings
Expand test data beyond a single user
In your first 10 tests, testWithNewUser was enough on its own, and tests still added bikes through the Manage fleet UI. Past 20 tests, repeating domain setup in the browser slows tests down again, and more flows depend on specific starting states (a bike to book, a full fleet, or a teammate with a different role) before the interesting part begins.
Keep testWithNewUser as the starting point for every signed-in test, and give it fixtures that set up domain data programmatically:
- Start every account empty and add only what the test needs. A
fleetfixture exposesfleet.add(...),fleet.set(...), andfleet.seed()(the full eight-bike office), backed by BikeBook's Fleet API (PUT /api/fleet). A test that books one bike adds one bike, so its setup says exactly what it depends on. - Add teammates with automatic teardown. Permission checks, such as verifying that an owner can cancel a member's booking, need two accounts in the same team.
team.addMember()invites a second user who signs up in their own browser context, and closes that browser and deletes the account when the test finishes.
Every test still gets its own user, for the same reason as in Your first 10 tests: creating a user through the API takes milliseconds, and tests that never share an account can't overwrite each other's data, whatever order or machine they run on.


To call the Fleet API, the fixture needs the new team's API key, so BikeBook's internal user endpoint now returns it alongside the session. In suites/03-scaled-suite, support/fixtures.ts extends the same testWithNewUser with fleet and team:
export const testWithNewUser = base.extend<{
newUser: NewUser;
fleet: FleetFixture;
team: TeamFixture;
}>({
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 },
],
fleet: async ({ newUser, request }, use) => {
let current: Bike[] = [];
const set = async (bikes: Bike[]) => {
current = [...bikes];
return setFleet(request, newUser.apiKey, current);
};
await use({
seed: () => set(OFFICE_FLEET),
set,
add: (...bikes) => set([...current, ...bikes]),
});
},
// team.addMember() invites a teammate in a second browser context
// and cleans up both the browser and account in teardown.
});Each test then declares only the bikes or teammates it needs:
// Needs the whole office: seed all eight bikes.
testWithNewUser(
"lists the office's bikes with their type",
async ({ page, fleet }) => {
await fleet.seed();
await page.goto("/dashboard");
await expect(page.getByRole("rowheader")).toHaveText([
"Road 1", "Road 2", "City 1", "City 2",
"E-City 1", "E-City 2", "E-City 3", "Cargo",
]);
},
);
// Needs one bike: add only the bike this test books.
testWithNewUser(
"a booked slot shows who has the bike",
async ({ page, fleet }) => {
await fleet.add({ name: "E-City 2", type: "e-city" });
await book(page, "E-City 2", "morning", daysFromNow(3));
await expect(bikeRow(page, "E-City 2")).toContainText("Booked by you");
},
);
// Multi-user: one bike and a teammate in a second browser.
testWithNewUser(
"owners can cancel a member's booking",
async ({ page, fleet, team }) => {
await fleet.add({ name: "Road 2", type: "road" });
const date = daysFromNow(7);
const member = await team.addMember();
await book(member.page, "Road 2", "morning", date);
await page.goto(`/dashboard?date=${date}`);
await page.getByRole("button", { name: "Cancel Road 2 morning" }).click();
await expect(bookButton(page, "Road 2", "morning")).toBeVisible();
},
);With isolated accounts and programmatic setup in milliseconds, deeper flows like plan upgrades start straight on the page under test. Hover or click the ai.do(...) line to inspect its compiled Playwright code:
import { expect, testWithNewUser } from "../../support/fixtures"; testWithNewUser.describe("upgrading", () => { // Programmatic user created via API in milliseconds, // isolated to this test and deleted automatically afterward. testWithNewUser( "upgrading to Plus records exactly one payment", async ({ page, ai }) => { await page.goto("/pricing"); await expect(page).toHaveURL("/dashboard/team?payment=success"); const payments = await (await page.request.get("/api/payment")).json(); expect(payments).toHaveLength(1); expect(payments[0]).toMatchObject({ planName: "Plus", amount: 1200, currency: "USD", }); }, );});Survive the flake cliff
A flake is a test that sometimes passes and sometimes fails on the same code. Engineers who regularly see failing test runs lose trust in the suite almost immediately: unless you can keep your suite passing close to 99% of the time, confidence erodes and pull request failures start getting ignored or blindly re-run.
Even with a great Playwright setup, a 100-test suite will end up flaking. Look at how quickly a small per-test flake rate turns pull requests red:
Retries exist for good reason. Rare, one-in-a-thousand flakes are usually not worth chasing, and a single retry absorbs those blips without holding up merges. Where flakes really hurt is the one-in-a-hundred to one-in-ten range: at a 5% per-test flake rate, even with one retry, more than one in five pull requests fails on a 100-test suite. Failures that happen that often are normally real bugs that your users are hitting too, so they are worth fixing.
Holding a 100-test suite near a 99% pass rate is completely doable, as long as you do not expect it to happen on day one and stay there on its own. It takes looking into your worst flakes on a regular basis.
Fix the two most unstable tests every week
The simplest habit that keeps a growing suite near 99% is to deal with the two most unstable tests every week (see also The no-flake strategy and Solve your most common flakes every week).
Increasingly, teams automate this as a weekly scheduled job run by a coding agent: pull the two most unstable tests from the past week, inspect why they failed, and open a pull request suggesting a fix to either the application or the test.


Whether an agent runs the job automatically or an engineer takes a quick pass once a week, the flow is the same four steps. Switch between MCP and CLI on any step to see how an agent or developer runs it:
-
Check: find the two most unstable tests
Rank tests on your default branch by pass rate over the last 7 days and pick the two tests causing the most failures.
Find the two most unstable testsYouWhat are our two most unstable end-to-end tests?Let me check test pass rates on main over the last 7 days.
MCP toolanalytics_query{ "dataset": "test-runs", "metric": "pass-rate", "groupBy": "test", "where": "branch = main", "period": "7D" }Your two most unstable tests on main this week are "a member books a bike for next week" (91.4% pass rate) and "a name typed straight after opening settings is saved" (94.8% pass rate).
$npx endform@latestHover or click any highlighted flag to see what it does.
-
Inspect: compare a failing attempt against a passing run
Pull recent runs for each of those tests that failed or needed a retry, then compare a failing attempt side by side with a recent passing run to see the exact step, screenshot, and network or console output where they diverged.
Inspect why the failing tests failedYouCan you inspect why those two tests failed?I'll pull recent retried runs for each test and inspect the failing attempts. Endform includes a diff against a recent passing run automatically when one is available.
MCP toolsamples_query{ "dataset": "test-runs", "where": "test.id = <testId>, testRun.testAttemptsCount > 1", "period": "7D", "limit": 5 }MCP tooltest_attempt_inspect{ "testAttemptId": "<testAttemptId>" }Found both root causes: in "a name typed straight after opening settings is saved", the Suspense fallback renders an editable form that wipes typed input when /api/user resolves (app bug). In "a member books a bike for next week", waitForTimeout(500) expires before the chosen date finishes loading (test bug).
$npx endform@latest$npx endform@latestHover or click any highlighted flag to see what it does.
-
Fix: solve the root cause in the app or the test
Once you see where the failing and passing runs diverge, decide whether the race belongs to your application or to the test. Here is what a weekly flake pull request looks like in BikeBook, fixing one real app bug and one flaky test wait together:
Open#42See BikeBook bug write-upFix weekly flakes: settings form hydration race and booking date waitendform-agent wants to merge intomainfromfix/weekly-flakes+4-2Fixes the two most unstable tests on main from the past 7 days: one application race in Settings and one fixed timeout in the bookings test.
app/(dashboard)/dashboard/general/page.tsxApp fixDisable the Suspense fallback form until user data resolves so neither fast tests nor users on slow connections lose typed input.
function AccountForm({ state, nameValue = "", emailValue = "",+ disabled = false, }: AccountFormProps) { // ...+ disabled={disabled} // ...-<Suspense fallback={<AccountForm state={state} />}>+<Suspense fallback={<AccountForm state={state} disabled />}> <AccountFormWithData state={state} /> </Suspense>tests/bookings.spec.tsTest fixReplace the fixed 500ms sleep after picking a date with an assertion that waits for the chosen day to render.
await test.step("Pick a day next week on the bikes page", async () => { await page.goto("/dashboard"); await page.getByRole("textbox", { name: "Date" }).fill(nextWeek);- await page.waitForTimeout(500);+ await expect(page.getByText(formatDay(nextWeek))).toBeVisible(); }); -
Verify and merge
Before merging the pull request, run the fixed specs repeatedly on Endform so you see them pass every time across isolated runs, then merge the PR.
Re-run the fixed specs ten times before mergingYouRun both specs 10 times on Endform with retries off to make sure the fixes hold.Starting a repeated suite run on Endform with retries disabled.
MCP toolsuite_run_startLocal MCP{ "directory": "/path/to/repo/suites/05-flake-lab", "testFileFilters": [ "tests/bookings.spec.ts", "tests/account.spec.ts" ], "repeatEach": 10, "retries": 0 }All 20 repeated runs passed on the first attempt in 18s with 0 retries. The pull request is ready to merge.
$npx endform@latestHover or click any highlighted flag to see what it does.
Keep 100 tests as fast as 10
When Endform runs your suite, every test gets its own isolated machine at the same time. That changes how suite duration behaves as you grow: total wall-clock time is set by your single slowest test, not the sum of all 100 tests.


Three habits keep run time flat as your suite grows organically from 10 tests to 100:
- Keep every test isolated. Because every signed-in test creates its own user with
testWithNewUser, no test depends on another, and nothing has to run serially or wait in a queue. - Set up state through fixtures, not the UI. Clicking through setup is the most common reason a test gets slow. When a test needs bikes or a teammate,
fleetandteamcreate them in milliseconds, so browser time goes to the behavior under test. - Split your slowest test when it covers two flows. Tests naturally pick up a few steps as features ship, and that's fine. Every so often, sort your tests by duration and look at the slowest one: if it finishes one flow and then carries on into a second, split it in two and start the second test from a fixture instead of replaying the first flow.
Here is today's scheduled run of all 103 BikeBook tests on Endform, finishing in about 30 seconds:
Last updated