Playwright NotesRohit’s interview study guide
Chapter 14

Project: Testing the Practice Shop End to End

A complete end-to-end suite for the Practice Shop, built the way a team would build it: the test plan, the project layout (config, a setup project that signs in once, fixtures, page objects, test data, tags), every file of the suite, the run in Chromium, Firefox and WebKit, a sharded GitHub Actions workflow, and how to talk about it in an interview. Every file on this page belongs to one project, and every run shown is a real run with Playwright 1.65.1 against the Practice Shop.

6 topics
Parts marked Advanced are extra depth. Skip them on a first read or a quick revision.

#The test plan

Added

A suite starts as a plan, not as code. The plan answers three questions a lead will be asked in the first week: what are we protecting, what does it cost, and what stays out? Chapter 3 showed the thinking on one feature; this is the same thinking across the whole shop, written down so the team (and an interviewer) can argue with it.

The mental model: a budget. Every E2E test costs seconds on every run, minutes of maintenance a year, and some risk of flaking. You spend that budget on the journeys where a break costs the most, and buy everything else more cheaply lower down. For the Practice Shop the budget is about 20 tests, under 30 seconds on a laptop, in three browsers.

JourneyRisk if brokenE2E testsLeft to cheaper tests
Sign innobody can use the shophappy path (smoke), wrong password, locked account, redirect back after sign-inpassword rules, the error copy
Find productscan't buy what you can't findsearch (smoke), category filter, no matches, sold-out can't be addedsorting order, every filter combination (component tests)
Cartwrong totals, lost salesadd from the shop (smoke), quantity changes the totals, removing the last itemrounding for every price (unit test of the total)
Checkoutlost money, angry customersplace an order (smoke), express fee, promo code, bad code, promo service down, validation blocks the order, delivery dateeach validation rule, the promo maths (unit), the promo API itself (API test)
Accountsupport ticketsthe order appears in the history, the CSV downloadthe CSV format edge cases (unit)
Look and feelcosmeticnone here (Chapter 10's visual tests if the team wants them)

Some decisions in that plan are worth saying out loud, because each is a trade-off:

  • Five smoke tests, one per journey, tagged @smoke. They run first and fast (a few seconds), on every push, and they're the ones to run against production after a deploy.
  • Sign in through the form once per run, in a setup project, and reuse the saved session everywhere else. Only login.spec.ts exercises the form itself (Chapter 8 explains why this is the standard pattern).
  • Arrange through state, act through the UI. A cart test doesn't need to click "Add to cart" to get a cart; it can put the cart in place directly, the way a real suite would call an API to create test data. Only the one test that is about adding from the shop clicks the button.
  • Mock only what you can't make happen. The promo service being down is mocked with page.route (Chapter 9); everything else runs against the real shop.
  • Three browser engines on every run. The suite is small enough that Chromium, Firefox and WebKit together still take under half a minute, so there's no reason to skip two of them. When a suite grows, the usual split is all engines on main and nightly, Chromium only on pull requests.

#The project layout

Added

The layout follows the shape most Playwright teams converge on, and each folder has one job:

PathWhat it holds
playwright.config.tshow to run: browsers (projects), the setup dependency, reporters, retries, traces, baseURL
tests/data.tsthe test data: users, products, customer details, where the saved session lives
tests/auth.setup.tsthe setup project's only test: sign in through the form and save the session
tests/fixtures.tsthe suite's own test: page objects as fixtures, a cartWith helper, an automatic check for page errors
pages/*.tspage objects: one class per page, holding its locators and actions
tests/*.spec.tsthe tests, one file per journey, written as what the user does and sees
playwright/.auth/the saved session, written at run time (git-ignored, never committed)

The rule that keeps it maintainable: tests say what, page objects say where, fixtures say how to get there. A test reads like the plan ("add the mouse, open the cart, the total is $29.50"); when a label changes, one page object changes; when the way to set up state changes, one fixture changes. Chapter 7 explains fixtures and page objects in depth; here's how they fit together in one project.

playwright.config.ts
import { defineConfig, devices } from "@playwright/test";
import { AUTH } from "./tests/data";

export default defineConfig({
  testDir: "./tests",
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 1 : undefined,
  // Locally: a line per test and an HTML report. On CI: a blob per shard (merged afterwards) and GitHub annotations.
  reporter: process.env.CI ? [["blob"], ["github"]] : [["list"], ["html", { open: "never" }]],
  use: {
    baseURL: process.env.BASE_URL ?? "https://rohit-playwright.pages.dev",
    trace: "on-first-retry",
    screenshot: "only-on-failure",
  },
  projects: [
    // Signs in once and saves the session; every browser project below depends on it and starts from it.
    { name: "setup", testMatch: /.*\.setup\.ts/ },
    { name: "chromium", use: { ...devices["Desktop Chrome"], storageState: AUTH.rohit }, dependencies: ["setup"] },
    { name: "firefox", use: { ...devices["Desktop Firefox"], storageState: AUTH.rohit }, dependencies: ["setup"] },
    { name: "webkit", use: { ...devices["Desktop Safari"], storageState: AUTH.rohit }, dependencies: ["setup"] },
  ],
});
tests/data.ts
// Test data in one place: the users, products and customer details the tests use.
export const USERS = {
  rohit: { username: "rohit", password: "playwright", name: "Rohit" },
  locked: { username: "locked", password: "playwright" },
} as const;

export const PRODUCTS = {
  keyboard: { id: "kb-01", name: "Mechanical Keyboard", price: 89 },
  mouse: { id: "ms-01", name: "Wireless Mouse", price: 29.5 },
  soldOutMouse: { id: "ms-02", name: "Vertical Mouse", price: 45 },
  microphone: { id: "au-02", name: "USB Microphone", price: 74.99 },
  lightBar: { id: "dk-02", name: "Monitor Light Bar", price: 49 },
} as const;
export type Product = (typeof PRODUCTS)[keyof typeof PRODUCTS];

export const CUSTOMER = { email: "rohit@example.com", address: "12 Long Street, Toronto" };

// Where the setup project saves the signed-in session (add playwright/.auth to .gitignore).
export const AUTH = { rohit: "playwright/.auth/rohit.json" };

export const money = (n: number) => `$${n.toFixed(2)}`;
tests/auth.setup.ts
import { test as setup, expect } from "@playwright/test";
import { AUTH, USERS } from "./data";

// Runs once, before the browser projects: signs in through the real form and saves the session to a file.
// The shop keeps the signed-in user in localStorage ("shop-user"), and storageState saves localStorage as well as cookies.
setup("sign in as Rohit", async ({ page }) => {
  await page.goto("/practice/");
  await page.getByLabel("Username").fill(USERS.rohit.username);
  await page.getByLabel("Password").fill(USERS.rohit.password);
  await page.getByRole("button", { name: "Sign in" }).click();
  await expect(page.getByText(`Signed in as ${USERS.rohit.username}`)).toBeVisible();
  await page.context().storageState({ path: AUTH.rohit });
});
tests/fixtures.ts
import { test as base, expect } from "@playwright/test";
import { LoginPage } from "../pages/login-page";
import { ShopPage } from "../pages/shop-page";
import { CartPage } from "../pages/cart-page";
import { CheckoutPage, OrderPage } from "../pages/checkout-page";
import { AccountPage } from "../pages/account-page";
import type { Product } from "./data";

type ShopFixtures = {
  loginPage: LoginPage;
  shop: ShopPage;
  cart: CartPage;
  checkout: CheckoutPage;
  order: OrderPage;
  account: AccountPage;
  // Puts products straight into the cart, without clicking through the shop (the shop's "API" is its localStorage).
  cartWith: (...products: Product[]) => Promise<void>;
  // Runs in every test without being asked for: fails the test if the page throws an uncaught error.
  noPageErrors: void;
};

export const test = base.extend<ShopFixtures>({
  loginPage: async ({ page }, use) => use(new LoginPage(page)),
  shop: async ({ page }, use) => use(new ShopPage(page)),
  cart: async ({ page }, use) => use(new CartPage(page)),
  checkout: async ({ page }, use) => use(new CheckoutPage(page)),
  order: async ({ page }, use) => use(new OrderPage(page)),
  account: async ({ page }, use) => use(new AccountPage(page)),

  cartWith: async ({ page }, use) => {
    await use(async (...products) => {
      const lines = products.map((p) => ({ id: p.id, name: p.name, price: p.price, qty: 1 }));
      await page.goto("/practice/help"); // any page of the shop, to be on its origin
      await page.localStorage.setItem("shop-cart", JSON.stringify(lines)); // page.localStorage: 1.61+ (Chapter 8)
    });
  },

  noPageErrors: [
    async ({ page }, use) => {
      const errors: string[] = [];
      page.on("pageerror", (error) => errors.push(error.message));
      await use();
      expect(errors, "uncaught errors in the page").toEqual([]);
    },
    { auto: true },
  ],
});

export { expect } from "@playwright/test";
pages/login-page.ts
import { type Locator, type Page } from "@playwright/test";

// One class per page: its locators, found the way a user finds things, and the few actions tests need.
// Page objects don't check outcomes; the tests do, so a test reads as what the user does and sees.
export class LoginPage {
  readonly username: Locator;
  readonly password: Locator;
  readonly signInButton: Locator;
  readonly error: Locator;

  constructor(readonly page: Page) {
    this.username = page.getByLabel("Username");
    this.password = page.getByLabel("Password");
    this.signInButton = page.getByRole("button", { name: "Sign in" });
    this.error = page.getByRole("alert");
  }
  async goto(path = "/practice/") {
    await this.page.goto(path);
  }
  async signIn(username: string, password: string) {
    await this.username.fill(username);
    await this.password.fill(password);
    await this.signInButton.click();
  }
}
pages/shop-page.ts
import { expect, type Locator, type Page } from "@playwright/test";

export class ShopPage {
  readonly search: Locator;
  readonly category: Locator;
  readonly products: Locator;
  readonly status: Locator;
  readonly cartLink: Locator;

  constructor(readonly page: Page) {
    this.search = page.getByLabel("Search products");
    this.category = page.getByLabel("Category");
    this.products = page.getByRole("list", { name: "Products" }).getByRole("listitem");
    this.status = page.locator("[data-products-status]");
    this.cartLink = page.getByRole("link", { name: /^Cart \(\d+\)$/ });
  }
  async goto() {
    await this.page.goto("/practice/shop");
    await expect(this.products.first()).toBeVisible(); // products arrive after a delay
  }
  product(name: string) {
    return this.products.filter({ has: this.page.getByRole("heading", { name, exact: true }) });
  }
  async add(name: string) {
    await this.product(name).getByRole("button", { name: "Add to cart" }).click();
  }
}
pages/cart-page.ts
import { type Locator, type Page } from "@playwright/test";

export class CartPage {
  readonly total: Locator;
  readonly empty: Locator;

  constructor(readonly page: Page) {
    this.total = page.getByTestId("cart-total");
    this.empty = page.getByText("Your cart is empty.");
  }
  async goto() {
    await this.page.goto("/practice/cart");
  }
  row(name: string) {
    return this.page.getByRole("row", { name: new RegExp(name) });
  }
  quantity(name: string) {
    return this.page.getByLabel(`Quantity of ${name}`, { exact: true });
  }
  async increase(name: string) {
    await this.page.getByRole("button", { name: `Increase quantity of ${name}` }).click();
  }
  async remove(name: string) {
    await this.page.getByRole("button", { name: `Remove ${name}` }).click();
  }
}
pages/checkout-page.ts
import { type Locator, type Page } from "@playwright/test";

export class CheckoutPage {
  readonly total: Locator;
  readonly promoMessage: Locator;
  readonly errorSummary: Locator;
  readonly placeOrderButton: Locator;

  constructor(readonly page: Page) {
    this.total = page.getByTestId("order-total");
    this.promoMessage = page.locator("#promo-message");
    this.errorSummary = page.getByRole("alert");
    this.placeOrderButton = page.getByRole("button", { name: "Place order" });
  }
  async goto() {
    await this.page.goto("/practice/checkout");
  }
  async fillDetails(details: { email: string; address: string }) {
    await this.page.getByLabel("Email").fill(details.email);
    await this.page.getByLabel("Delivery address").fill(details.address);
    await this.page.getByLabel("I agree to the terms").check();
  }
  async chooseExpress() {
    await this.page.getByLabel("Express").check();
  }
  async applyPromo(code: string) {
    await this.page.getByLabel("Promo code").fill(code);
    await this.page.getByRole("button", { name: "Apply" }).click();
  }
  async placeOrder() {
    await this.placeOrderButton.click();
  }
}

export class OrderPage {
  readonly heading: Locator;
  readonly deliveryEstimate: Locator;

  constructor(readonly page: Page) {
    this.heading = page.getByRole("heading", { level: 1 });
    this.deliveryEstimate = page.getByTestId("delivery-estimate");
  }
  confirmation(orderId: string) {
    return this.page.getByText(`Your order ${orderId} is confirmed.`);
  }
  totalPaid(amount: string) {
    return this.page.getByText(`Total paid on delivery: ${amount}`);
  }
}
pages/account-page.ts
import { type Locator, type Page } from "@playwright/test";

export class AccountPage {
  readonly orders: Locator;
  readonly downloadButton: Locator;

  constructor(readonly page: Page) {
    this.orders = page.getByRole("table", { name: "Your orders" }).getByRole("row");
    this.downloadButton = page.getByRole("button", { name: "Download orders (CSV)" });
  }
  async goto() {
    await this.page.goto("/practice/account");
  }
}
What’s happening
  1. The config defines four projects. setup matches only *.setup.ts files; chromium, firefox and webkit each list it in dependencies, so it runs first, once, and each browser starts every test from the session it saved (storageState: AUTH.rohit). fullyParallel lets tests from the same file run at the same time, and baseURL can be overridden with BASE_URL to point the same suite at a local build or staging.
  2. CI settings switch on process.env.CI: forbidOnly fails the run if someone commits a test.only, failures are retried twice (and a retry records a trace, on-first-retry), each CI machine uses one worker (the docs' advice for stable CI runs; the parallelism comes from shards), and the reporter becomes blob (one file per shard, merged later) plus github (failures as annotations on the pull request). Locally you get the list and an HTML report.
  3. auth.setup.ts signs in through the real form and calls storageState({ path }). The shop keeps the signed-in user in localStorage under shop-user, and a storage state file saves localStorage as well as cookies, so every test that loads it starts signed in as Rohit without touching the form.
  4. fixtures.ts extends Playwright's test. Each page object is a fixture, so a test just asks for { shop, cart, checkout }. cartWith(...) writes the cart straight into localStorage with page.localStorage.setItem (1.61+), from the shop's own origin (storage belongs to an origin, so it first visits /practice/help, a page with no redirects): the equivalent of creating test data through an API. noPageErrors is an auto fixture: it runs for every test without being asked for, and fails the test if the page threw an uncaught error, even if every assertion passed.
  5. The page objects hold locators built from roles, labels and test ids, plus actions like signIn and applyPromo. They don't assert outcomes. The one expect inside them is in ShopPage.goto, and it's a wait (for the products that arrive after 0.7 s), not a check of the feature.
  6. ShopPage.product(name) shows a pattern you'll reuse: a method that returns a locator, scoped to the product card whose heading is exactly that name. Tests then chain on it (shop.product("Vertical Mouse").getByRole("button")), so a page object never needs a method for every button on every card.
  7. tests/data.ts is plain TypeScript, so a typo in a product name is a compile error and Product is a real type the cartWith fixture can require. Prices live next to the names, but the tests still write expected totals as literals ("$198.98"): computing the expectation with the same formula as the app would hide a wrong formula.
AdvancedWhat isn't in the layout, on purpose
  • No utils/ grab bag. Helpers that need the page are fixtures; helpers that don't are plain functions in the file that uses them, until two files need them.
  • No base page class. Five small page objects don't share enough to need inheritance; composition (a page object holding a header object, say) ages better when they grow.
  • No test ids added for tests' sake. The shop already has data-testid on the totals and product cards, and the suite uses them only where there's no good role or label (the money).
  • No globalSetup file. A setup project does the same job and shows up in the report, with traces and retries, which globalSetup doesn't (the Playwright docs recommend projects for this).

#The suite, file by file

Added

Five spec files, one per journey, 20 tests. Each test arranges its own state, does one thing and checks what the user sees, so any of them can run alone, in any order, in any browser. Then the whole suite runs in all three engines, which is the check that matters before calling it done: a suite that's only been run in Chromium has been tested in Chromium.

tests/login.spec.ts
import { test, expect } from "./fixtures";
import { USERS } from "./data";

// The one file that signs in through the form: start signed out, whatever the project's saved session says.
test.use({ storageState: { cookies: [], origins: [] } });

test.describe("sign in", () => {
  test("a user can sign in and lands on the products", { tag: "@smoke" }, async ({ page, loginPage }) => {
    await loginPage.goto();
    await loginPage.signIn(USERS.rohit.username, USERS.rohit.password);

    await expect(page).toHaveURL("/practice/shop");
    await expect(page.getByText("Signed in as rohit")).toBeVisible();
  });

  test("a wrong password is refused", async ({ page, loginPage }) => {
    await loginPage.goto();
    await loginPage.signIn(USERS.rohit.username, "wrong-password");

    await expect(loginPage.error).toHaveText("Wrong username or password.");
    await expect(page).toHaveURL("/practice/");
  });

  test("a locked account can't sign in", async ({ loginPage }) => {
    await loginPage.goto();
    await loginPage.signIn(USERS.locked.username, USERS.locked.password);

    await expect(loginPage.error).toHaveText("This account is locked. Contact support.");
  });

  test("a signed-out visitor is sent to sign in, then back to the page they wanted", async ({ page, loginPage }) => {
    await loginPage.goto("/practice/cart");
    await expect(page).toHaveURL("/practice/?next=%2Fpractice%2Fcart");

    await loginPage.signIn(USERS.rohit.username, USERS.rohit.password);

    await expect(page).toHaveURL("/practice/cart");
  });
});
tests/shop.spec.ts
import { test, expect } from "./fixtures";
import { PRODUCTS } from "./data";

test.describe("finding products", () => {
  test.beforeEach(async ({ shop }) => {
    await shop.goto();
  });

  test("search finds products by name", { tag: "@smoke" }, async ({ shop }) => {
    await shop.search.fill("mouse");

    await expect(shop.products.getByRole("heading")).toHaveText([PRODUCTS.mouse.name, PRODUCTS.soldOutMouse.name]);
  });

  test("the category filter shows only that category", async ({ shop }) => {
    await shop.category.selectOption("Audio");

    await expect(shop.products).toHaveCount(2);
    await expect(shop.products.filter({ hasNotText: "Audio" })).toHaveCount(0);
  });

  test("a search with no matches says so", async ({ shop }) => {
    await shop.search.fill("teapot");

    await expect(shop.status).toHaveText("No products match “teapot”.");
    await expect(shop.products).toHaveCount(0);
  });

  test("a sold-out product can't be added", async ({ shop }) => {
    const card = shop.product(PRODUCTS.soldOutMouse.name);

    await expect(card).toContainText("Sold out");
    await expect(card.getByRole("button", { name: "Add to cart" })).toBeDisabled();
  });
});
tests/cart.spec.ts
import { test, expect } from "./fixtures";
import { PRODUCTS, money } from "./data";

test.describe("the cart", () => {
  test("adding from the shop puts the product in the cart", { tag: "@smoke" }, async ({ page, shop, cart }) => {
    await shop.goto();

    await shop.add(PRODUCTS.mouse.name);

    await expect(shop.cartLink).toHaveText("Cart (1)");
    await shop.cartLink.click();
    await expect(cart.row(PRODUCTS.mouse.name)).toBeVisible();
    await expect(cart.total).toHaveText(money(PRODUCTS.mouse.price));
    await expect(page).toHaveURL("/practice/cart");
  });

  test("raising a quantity updates the subtotal and the total", async ({ cart, cartWith }) => {
    await cartWith(PRODUCTS.microphone, PRODUCTS.lightBar);
    await cart.goto();

    await cart.increase(PRODUCTS.microphone.name);

    await expect(cart.quantity(PRODUCTS.microphone.name)).toHaveText("2");
    await expect(cart.row(PRODUCTS.microphone.name)).toContainText("$149.98");
    await expect(cart.total).toHaveText("$198.98");
  });

  test("removing the last item empties the cart", async ({ cart, cartWith }) => {
    await cartWith(PRODUCTS.keyboard);
    await cart.goto();

    await cart.remove(PRODUCTS.keyboard.name);

    await expect(cart.empty).toBeVisible();
    await expect(cart.page.getByRole("link", { name: "Cart (0)" })).toBeVisible();
  });
});
tests/checkout.spec.ts
import { test, expect } from "./fixtures";
import { CUSTOMER, PRODUCTS } from "./data";

test.describe("checkout", () => {
  test("a customer can place an order and sees the confirmation", { tag: "@smoke" }, async ({ page, cartWith, checkout, order }) => {
    await cartWith(PRODUCTS.mouse);
    await checkout.goto();
    await expect(page.getByLabel("Full name")).toHaveValue("Rohit");
    await checkout.fillDetails(CUSTOMER);

    await checkout.placeOrder();

    await expect(order.heading).toHaveText("Thank you, Rohit!");
    await expect(order.confirmation("ORD-1001")).toBeVisible();
    await expect(order.totalPaid("$29.50")).toBeVisible();
  });

  test("express delivery adds $9.99 to the total", async ({ cartWith, checkout, order }) => {
    await cartWith(PRODUCTS.mouse, PRODUCTS.lightBar);
    await checkout.goto();
    await expect(checkout.total).toHaveText("$78.50");

    await checkout.chooseExpress();

    await expect(checkout.total).toHaveText("$88.49");
    await checkout.fillDetails(CUSTOMER);
    await checkout.placeOrder();
    await expect(order.totalPaid("$88.49")).toBeVisible();
  });

  test("SAVE10 takes 10% off the total", async ({ cartWith, checkout }) => {
    await cartWith(PRODUCTS.keyboard);
    await checkout.goto();

    await checkout.applyPromo("SAVE10");

    await expect(checkout.promoMessage).toHaveText("SAVE10 applied: 10% off.");
    await expect(checkout.total).toHaveText("$80.10");
  });

  test("an unknown promo code is refused and changes nothing", async ({ cartWith, checkout }) => {
    await cartWith(PRODUCTS.keyboard);
    await checkout.goto();

    await checkout.applyPromo("FREESTUFF");

    await expect(checkout.promoMessage).toHaveText("That code isn’t valid.");
    await expect(checkout.total).toHaveText("$89.00");
  });

  test("if the promo check fails, the customer is asked to try again", async ({ page, cartWith, checkout }) => {
    await page.route("**/practice/api/promos/*", (route) => route.fulfill({ status: 503 }));
    await cartWith(PRODUCTS.keyboard);
    await checkout.goto();

    await checkout.applyPromo("SAVE10");

    await expect(checkout.promoMessage).toHaveText("Couldn’t check the code. Try again.");
    await expect(checkout.total).toHaveText("$89.00");
  });

  test("missing details block the order", async ({ page, cartWith, checkout }) => {
    await cartWith(PRODUCTS.mouse);
    await checkout.goto();

    await checkout.placeOrder();

    await expect(checkout.errorSummary).toHaveText("Please fix 3 problems before placing your order.");
    await expect(page.getByText("Enter your email.")).toBeVisible();
    await expect(page).toHaveURL("/practice/checkout");
  });

  test("the confirmation shows the delivery date", async ({ page, cartWith, checkout, order }) => {
    await page.clock.setFixedTime(new Date("2026-11-24T12:00:00Z"));
    await cartWith(PRODUCTS.mouse);
    await checkout.goto();
    await checkout.fillDetails(CUSTOMER);

    await checkout.placeOrder();

    await expect(order.deliveryEstimate).toHaveText("Estimated delivery: Saturday, November 28");
  });
});
tests/account.spec.ts
import { readFile } from "node:fs/promises";
import { test, expect } from "./fixtures";
import { CUSTOMER, PRODUCTS } from "./data";

test.describe("order history", () => {
  test.beforeEach(async ({ page, cartWith, checkout, order }) => {
    // These tests need a past order, so each one places its own (with a fixed clock, so the date is known).
    await page.clock.setFixedTime(new Date("2026-11-24T12:00:00Z"));
    await cartWith(PRODUCTS.mouse);
    await checkout.goto();
    await checkout.fillDetails(CUSTOMER);
    await checkout.placeOrder();
    await expect(order.heading).toHaveText("Thank you, Rohit!");
  });

  test("a placed order appears on the account page", async ({ account }) => {
    await account.goto();

    await expect(account.orders).toHaveCount(2); // the header row and one order
    await expect(account.orders.nth(1)).toHaveText(/ORD-1001\s*2026-11-24\s*1\s*\$29\.50/);
  });

  test("the order history downloads as a CSV file", async ({ page, account }) => {
    await account.goto();

    const downloading = page.waitForEvent("download");
    await account.downloadButton.click();
    const download = await downloading;

    expect(download.suggestedFilename()).toBe("orders.csv");
    expect(await readFile(await download.path(), "utf8")).toBe("order,date,items,total\nORD-1001,2026-11-24,1,29.50\n");
  });
});
npx playwright test
Running 61 tests using 9 workers

  ✓   1 [setup] › tests/auth.setup.ts:6:1 › sign in as Rohit (1.1s)
  ✓   7 [chromium] › tests/checkout.spec.ts:31:3 › checkout › SAVE10 takes 10% off the total (721ms)
  ✓   3 [chromium] › tests/cart.spec.ts:17:3 › the cart › raising a quantity updates the subtotal and the total (726ms)
  ✓   9 [chromium] › tests/checkout.spec.ts:41:3 › checkout › an unknown promo code is refused and changes nothing (925ms)
  ✓   8 [chromium] › tests/cart.spec.ts:28:3 › the cart › removing the last item empties the cart (929ms)
  ✓  12 [chromium] › tests/checkout.spec.ts:62:3 › checkout › missing details block the order (400ms)
  ✓  11 [chromium] › tests/checkout.spec.ts:51:3 › checkout › if the promo check fails, the customer is asked to try again (512ms)
  ✓   4 [chromium] › tests/cart.spec.ts:5:3 › the cart › adding from the shop puts the product in the cart @smoke (1.5s)
  ✓  14 [chromium] › tests/login.spec.ts:8:3 › sign in › a user can sign in and lands on the products @smoke (1.1s)
  ✓   6 [chromium] › tests/checkout.spec.ts:5:3 › checkout › a customer can place an order and sees the confirmation @smoke (2.3s)
  ✓  15 [chromium] › tests/login.spec.ts:16:3 › sign in › a wrong password is refused (1.1s)
  ✓   5 [chromium] › tests/account.spec.ts:16:3 › order history › a placed order appears on the account page (2.3s)
  ✓  16 [chromium] › tests/login.spec.ts:24:3 › sign in › a locked account can't sign in (1.1s)
  ✓   2 [chromium] › tests/account.spec.ts:23:3 › order history › the order history downloads as a CSV file (2.3s)
  ✓  10 [chromium] › tests/checkout.spec.ts:18:3 › checkout › express delivery adds $9.99 to the total (2.4s)
  ✓  17 [chromium] › tests/login.spec.ts:31:3 › sign in › a signed-out visitor is sent to sign in, then back to the page they wanted (1.1s)
  ✓  13 [chromium] › tests/checkout.spec.ts:73:3 › checkout › the confirmation shows the delivery date (1.8s)
  ✓  19 [chromium] › tests/shop.spec.ts:15:3 › finding products › the category filter shows only that category (1.0s)
  ✓  21 [chromium] › tests/shop.spec.ts:29:3 › finding products › a sold-out product can't be added (1.0s)
  ✓  18 [chromium] › tests/shop.spec.ts:9:3 › finding products › search finds products by name @smoke (1.8s)
  ✓  20 [chromium] › tests/shop.spec.ts:22:3 › finding products › a search with no matches says so (1.8s)
  ✓  26 [firefox] › tests/cart.spec.ts:28:3 › the cart › removing the last item empties the cart (2.4s)
  ✓  25 [firefox] › tests/cart.spec.ts:17:3 › the cart › raising a quantity updates the subtotal and the total (2.8s)
  ✓  31 [firefox] › tests/checkout.spec.ts:51:3 › checkout › if the promo check fails, the customer is asked to try again (1.3s)
  ✓  32 [firefox] › tests/checkout.spec.ts:62:3 › checkout › missing details block the order (1.6s)
  ✓  23 [firefox] › tests/account.spec.ts:23:3 › order history › the order history downloads as a CSV file (5.6s)
  ✓  22 [firefox] › tests/account.spec.ts:16:3 › order history › a placed order appears on the account page (5.3s)
  ✓  35 [firefox] › tests/login.spec.ts:16:3 › sign in › a wrong password is refused (1.9s)
  ✓  34 [firefox] › tests/login.spec.ts:8:3 › sign in › a user can sign in and lands on the products @smoke (2.0s)
  ✓  33 [firefox] › tests/checkout.spec.ts:73:3 › checkout › the confirmation shows the delivery date (3.4s)
  ✓  28 [firefox] › tests/checkout.spec.ts:5:3 › checkout › a customer can place an order and sees the confirmation @smoke (5.2s)
  ✓  29 [firefox] › tests/checkout.spec.ts:31:3 › checkout › SAVE10 takes 10% off the total (3.9s)
  ✓  27 [firefox] › tests/checkout.spec.ts:18:3 › checkout › express delivery adds $9.99 to the total (5.9s)
  ✓  36 [firefox] › tests/login.spec.ts:24:3 › sign in › a locked account can't sign in (2.8s)
  ✓  30 [firefox] › tests/checkout.spec.ts:41:3 › checkout › an unknown promo code is refused and changes nothing (5.3s)
  ✓  37 [firefox] › tests/login.spec.ts:31:3 › sign in › a signed-out visitor is sent to sign in, then back to the page they wanted (3.2s)
  ✓  38 [firefox] › tests/shop.spec.ts:9:3 › finding products › search finds products by name @smoke (3.9s)
  ✓  24 [firefox] › tests/cart.spec.ts:5:3 › the cart › adding from the shop puts the product in the cart @smoke (5.6s)
  ✓  41 [firefox] › tests/shop.spec.ts:29:3 › finding products › a sold-out product can't be added (3.9s)
  ✓  39 [firefox] › tests/shop.spec.ts:15:3 › finding products › the category filter shows only that category (4.7s)
  ✓  40 [firefox] › tests/shop.spec.ts:22:3 › finding products › a search with no matches says so (5.1s)
  ✓  45 [webkit] › tests/cart.spec.ts:17:3 › the cart › raising a quantity updates the subtotal and the total (1.4s)
  ✓  44 [webkit] › tests/cart.spec.ts:5:3 › the cart › adding from the shop puts the product in the cart @smoke (2.3s)
  ✓  49 [webkit] › tests/checkout.spec.ts:51:3 › checkout › if the promo check fails, the customer is asked to try again (1.5s)
  ✓  46 [webkit] › tests/cart.spec.ts:28:3 › the cart › removing the last item empties the cart (1.5s)
  ✓  42 [webkit] › tests/account.spec.ts:16:3 › order history › a placed order appears on the account page (3.5s)
  ✓  43 [webkit] › tests/account.spec.ts:23:3 › order history › the order history downloads as a CSV file (3.9s)
  ✓  52 [webkit] › tests/checkout.spec.ts:62:3 › checkout › missing details block the order (1.7s)
  ✓  50 [webkit] › tests/checkout.spec.ts:31:3 › checkout › SAVE10 takes 10% off the total (1.8s)
  ✓  51 [webkit] › tests/checkout.spec.ts:41:3 › checkout › an unknown promo code is refused and changes nothing (1.5s)
  ✓  54 [webkit] › tests/login.spec.ts:8:3 › sign in › a user can sign in and lands on the products @smoke (1.7s)
  ✓  55 [webkit] › tests/login.spec.ts:16:3 › sign in › a wrong password is refused (1.6s)
  ✓  56 [webkit] › tests/login.spec.ts:24:3 › sign in › a locked account can't sign in (1.6s)
  ✓  47 [webkit] › tests/checkout.spec.ts:5:3 › checkout › a customer can place an order and sees the confirmation @smoke (3.5s)
  ✓  48 [webkit] › tests/checkout.spec.ts:18:3 › checkout › express delivery adds $9.99 to the total (3.5s)
  ✓  57 [webkit] › tests/login.spec.ts:31:3 › sign in › a signed-out visitor is sent to sign in, then back to the page they wanted (1.4s)
  ✓  53 [webkit] › tests/checkout.spec.ts:73:3 › checkout › the confirmation shows the delivery date (2.6s)
  ✓  59 [webkit] › tests/shop.spec.ts:15:3 › finding products › the category filter shows only that category (1.7s)
  ✓  58 [webkit] › tests/shop.spec.ts:9:3 › finding products › search finds products by name @smoke (2.0s)
  ✓  61 [webkit] › tests/shop.spec.ts:29:3 › finding products › a sold-out product can't be added (1.6s)
  ✓  60 [webkit] › tests/shop.spec.ts:22:3 › finding products › a search with no matches says so (2.3s)

  61 passed (25.6s)
What’s happening
  1. The run: 61 tests, which is 20 tests × 3 browsers plus the one setup test. [setup] runs first; every browser test waits for it because of dependencies. They all pass in Chromium, Firefox and WebKit, in about half a minute with the machine's workers (more workers finish faster; the count is the machine's, not the config's).
  2. login.spec.ts clears the saved session with test.use({ storageState: { cookies: [], origins: [] } }), because this file is about signing in. Its four tests cover the happy path (smoke), both refusals with their exact messages, and the redirect: opening the cart signed out goes to /practice/?next=%2Fpractice%2Fcart, and signing in lands back on the cart.
  3. shop.spec.ts opens the shop in beforeEach (signed in already, from the saved session). Search checks the exact headings in order, the filter checks that nothing outside Audio is left (filter({ hasNotText: "Audio" }) must count 0), and the sold-out test checks both the label and the disabled button.
  4. cart.spec.ts: only the smoke test clicks "Add to cart", because adding is its subject; the other two start from cartWith(...). The quantity test checks three numbers ($74.99 × 2 = $149.98, plus $49.00 = $198.98) and removing the last item checks the empty message and the header's "Cart (0)".
  5. checkout.spec.ts is the biggest file because it's where the money is: the happy path (smoke), express ($78.50 → $88.49, then on the confirmation), SAVE10 ($89.00 → $80.10), an unknown code, the promo service returning 503 (mocked with page.route), validation (3 problems, still on checkout), and the delivery date with the clock fixed at 24 Nov 2026, 12:00 UTC, so "Saturday, November 28" is right in every time zone from UTC−11 to UTC+11.
  6. account.spec.ts needs a past order, so its beforeEach places one through checkout with a fixed clock. Then the history table has the header row plus ORD-1001 2026-11-24 1 $29.50, and the download test reads the real downloaded file and compares it byte for byte with the CSV the shop should produce.
  7. Every test got ORD-1001, even in parallel and across browsers, because each test's browser context has its own storage and so its own order counter. That's the isolation Chapter 3 asked for, delivered by the tools: no test can see another's cart or orders.
AdvancedRunning a slice of the suite

Most days nobody runs all 61. Here's the smoke set in one browser, the command for a quick check before pushing:

npx playwright test --grep @smoke --project=chromium
Running 5 tests using 4 workers

  ✓  1 [setup] › tests/auth.setup.ts:6:1 › sign in as Rohit (1.0s)
  ✓  3 [chromium] › tests/login.spec.ts:8:3 › sign in › a user can sign in and lands on the products @smoke (1.0s)
  ✓  2 [chromium] › tests/cart.spec.ts:5:3 › the cart › adding from the shop puts the product in the cart @smoke (1.1s)
  ✓  5 [chromium] › tests/checkout.spec.ts:5:3 › checkout › a customer can place an order and sees the confirmation @smoke (1.6s)
  ✓  4 [chromium] › tests/shop.spec.ts:9:3 › finding products › search finds products by name @smoke (1.8s)

  5 passed (3.6s)
What’s happening
  1. --grep @smoke selects the five tests tagged @smoke (tags match like words in the title, Chapter 2), and --project=chromium keeps it to one browser.
  2. The setup test still runs, although its title doesn't say @smoke: --grep doesn't filter a project's dependencies, because the tests that need the saved session can't run without it. (--no-deps skips them, for when you know the saved session is already there.)
  3. Five journeys checked in a few seconds. In CI the same command makes a good first job, before the full sharded run.
AdvancedEdge case: a test that uses the clock and a download

The account tests combine two things that often flake elsewhere, and neither needed a wait or a retry:

  • page.clock.setFixedTime(…) (Chapter 11) fixes Date.now() in the page, but timers keep running, so the shop's 1.2 s "placing order" delay still happens normally. Fixing the date is what makes 2026-11-24 predictable, in the table and in the file.
  • The download is started with page.waitForEvent("download") before the click, then awaited after it, so the event can't be missed. download.path() waits for the file to finish and returns where Playwright saved it, in every browser (Chapter 5).

#Running it in CI

Added

On CI the suite should give fast, trustworthy feedback on every pull request and a report you can debug from when something fails. Three ideas get you there. Sharding: split the tests across several machines that run at the same time (--shard=2/4 runs the second quarter). Blob reports: each shard writes its results as a blob file, and a final job merges them into one HTML report (Chapter 12 goes deeper into both). Artifacts with traces: a test that fails is retried, the retry records a trace, and the trace is in the report, so you can open the failure step by step without reproducing it.

The mental model: a relay with a photo finish. The runners (shards) run their legs at the same time; the merge job lines up every result into one picture; and every fall was filmed (the trace).

.github/workflows/e2e.yml
name: E2E tests
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  e2e:
    timeout-minutes: 30
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        shardIndex: [1, 2, 3, 4]
        shardTotal: [4]
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: lts/*
          cache: npm
      - name: Install dependencies
        run: npm ci
      - name: Install Playwright browsers
        run: npx playwright install --with-deps
      - name: Run shard ${{ matrix.shardIndex }} of ${{ matrix.shardTotal }}
        run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
      - name: Upload the blob report
        if: ${{ !cancelled() }}
        uses: actions/upload-artifact@v5
        with:
          name: blob-report-${{ matrix.shardIndex }}
          path: blob-report
          retention-days: 1

  report:
    if: ${{ !cancelled() }}
    needs: [e2e]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: lts/*
          cache: npm
      - name: Install dependencies
        run: npm ci
      - name: Download the blob reports
        uses: actions/download-artifact@v5
        with:
          path: all-blob-reports
          pattern: blob-report-*
          merge-multiple: true
      - name: Merge them into one HTML report
        run: npx playwright merge-reports --reporter html ./all-blob-reports
      - name: Upload the HTML report
        uses: actions/upload-artifact@v5
        with:
          name: html-report--attempt-${{ github.run_attempt }}
          path: playwright-report
          retention-days: 14
What’s happening
  1. Two jobs. e2e runs four times in parallel (the matrix), each with --shard=N/4; report waits for all four (needs: [e2e]) and runs even if some failed (if: ${{ !cancelled() }}), because the report matters most when something failed. fail-fast: false keeps the other shards running when one fails, so you see every failure, not just the first.
  2. Each shard is a clean Ubuntu machine: check out, install Node (with the npm cache), npm ci, then npx playwright install --with-deps, which downloads the browsers matching the installed Playwright version and the Linux libraries they need. GitHub sets CI=true, so the config switches to retries, forbidOnly and the blob and github reporters.
  3. The setup project runs in every shard. Each machine needs its own saved session, and dependencies makes sure it exists before that shard's tests start. That's one extra sign-in per shard: cheap.
  4. Blob reports go up as artifacts named blob-report-1 … blob-report-4, kept for a day because they're only needed by the merge job. The report job downloads all four into one folder (pattern + merge-multiple: true), runs merge-reports --reporter html, and uploads the HTML report for two weeks.
  5. What a failure looks like: the failing shard's job goes red; the github reporter puts an annotation with the error on the line of the test in the pull request's diff; and the merged HTML report shows the test with its retries, the screenshot from the failure, and the trace from the retry (open it with npx playwright show-trace or at trace.playwright.dev). A test that failed and then passed on retry is marked flaky, not passed: Chapter 11 is about what to do with those.
  6. This workflow passes actionlint (the site checks every workflow it shows), but it was not run on GitHub for this page: there's no repository behind this suite. The job structure and action versions follow the Playwright docs' sharding page (playwright.dev, read 24 Nov 2026), which uses checkout@v6, setup-node@v6, upload-artifact@v5 and download-artifact@v5.
AdvancedHow the tests split across shards

--shard splits the run into equal parts. With fullyParallel: true it splits by test, not by file, so the shards come out even. Here's the first of three shards, in Chromium only, run locally:

npx playwright test --shard=1/3 --project=chromium
Running 8 tests using 7 workers, shard 1 of 3

  ✓  1 [setup] › tests/auth.setup.ts:6:1 › sign in as Rohit (1.0s)
  ✓  8 [chromium] › tests/cart.spec.ts:28:3 › the cart › removing the last item empties the cart (373ms)
  ✓  3 [chromium] › tests/cart.spec.ts:17:3 › the cart › raising a quantity updates the subtotal and the total (421ms)
  ✓  4 [chromium] › tests/cart.spec.ts:5:3 › the cart › adding from the shop puts the product in the cart @smoke (1.2s)
  ✓  7 [chromium] › tests/checkout.spec.ts:5:3 › checkout › a customer can place an order and sees the confirmation @smoke (1.8s)
  ✓  5 [chromium] › tests/checkout.spec.ts:18:3 › checkout › express delivery adds $9.99 to the total (1.8s)
  ✓  6 [chromium] › tests/account.spec.ts:16:3 › order history › a placed order appears on the account page (1.8s)
  ✓  2 [chromium] › tests/account.spec.ts:23:3 › order history › the order history downloads as a CSV file (1.9s)

  8 passed (3.8s)
What’s happening
  1. "Running 8 tests …, shard 1 of 3": the setup test plus seven of the twenty Chromium tests. Shards 2 and 3 get the rest.
  2. The split mixes files (cart, checkout and account tests here), which is fullyParallel at work: without it, whole files are the unit of splitting, and one big file (like checkout.spec.ts) can make one shard much slower than the others.
  3. The setup test is in this shard too, and would be in every shard: a shard that runs tests from a project also runs that project's dependencies.
  4. Rule of thumb for how many shards: enough that each shard takes a few minutes. Below that, the fixed cost of each machine (checkout, npm ci, installing browsers, about a minute or more) is most of the time. This suite is far too small to need four shards; the workflow is written for the size it will grow to.
AdvancedMaking it faster as it grows
  • Cache nothing you can't trust. Caching ~/.cache/ms-playwright saves the browser download, but the Playwright docs don't recommend it (restoring the cache takes about as long as downloading, and the Linux dependencies still need installing). The official Docker image (Chapter 12) has browsers and dependencies baked in; its tags follow the Playwright version (the docs' CI page example is mcr.microsoft.com/playwright:v1.64.1-noble), and the tag must match the version in your package.json.
  • Run the smoke tests first. A separate quick job with --grep @smoke --project=chromium tells a pull request author in a minute that something basic is broken, before four shards spend their time.
  • Fewer browsers on pull requests. --project=chromium on pull requests and all three on main and nightly is a common compromise once the full run gets long.
  • --only-changed runs only the test files affected by changes since a git ref (--only-changed=origin/main), useful as a fast first pass on pull requests.

#What to say about it in an interview

Added

"Tell me about a test framework you built" is one of the most common questions for a senior or lead role, and this project gives you a concrete, honest example to talk through. A good answer has a shape: the goal, the decisions and why, how you kept it reliable and fast, and what you'd do next. Interviewers listen for trade-offs and numbers, not a list of tools.

Here's that shape, using this suite. Make it yours by swapping in your own app, numbers and war stories; never claim a production incident or scale you didn't have.

  1. The goal. "Protect the journeys that make money, give feedback on every pull request within minutes, and never be the reason a release is blocked by a flaky test."
  2. What's in, what's out. "About 20 E2E tests over five journeys, chosen by risk: sign-in, search, cart, checkout, account. Validation rules, pricing maths and the promo API are unit and API tests. One smoke test per journey."
  3. The structure. "A setup project signs in once and saves the session; tests start from it. Page objects hold locators, fixtures provide the page objects and set up data, tests read like the user's story. Test data is typed and in one file."
  4. Reliability. "No sleeps: web-first assertions and auto-waiting. Each test makes its own data, so everything runs fully parallel. Role and label locators, so refactors don't break tests. An automatic fixture fails any test whose page throws an uncaught error. The clock is fixed where dates matter. Only the promo service outage is mocked."
  5. Speed and scale. "Twenty tests in three browsers take about half a minute locally. In CI it's sharded with blob reports merged into one HTML report, retries with traces on the first retry, and failures annotated on the pull request."
  6. What's next. "Visual tests for the checkout page, an axe accessibility check per page, API tests for the promo endpoint, and a flaky-test budget: anything that flakes twice in a week gets fixed or quarantined with an owner."

#Your turn: extend the suite

Added
Your turn: a second user without a second login

The suite signs in as Rohit once, in the setup project. Add a fixture signedInAs(username, name) that starts a test signed in as anyone without using the form or a setup project, by writing the shop's shop-user entry before the page loads. Use it to check that Ana's account page shows "Signed in as ana", "Ana" as the display name, and "No orders yet.".

Show answer
tests/fixtures.ts
import { test as base } from "@playwright/test";

export const test = base.extend<{ signedInAs: (username: string, name: string) => Promise<void> }>({
  signedInAs: async ({ page }, use) => {
    await use(async (username, name) => {
      // Runs in every page of this test before the shop's own script, so the shop always finds a signed-in user.
      await page.addInitScript((user) => localStorage.setItem("shop-user", JSON.stringify(user)), { username, name });
    });
  },
});
export { expect } from "@playwright/test";
tests/account.spec.ts
import { test, expect } from "./fixtures";

test("Ana's account starts with no orders", async ({ page, signedInAs }) => {
  await signedInAs("ana", "Ana");

  await page.goto("/practice/account");

  await expect(page.getByText("Signed in as ana")).toBeVisible();
  await expect(page.getByLabel("Display name")).toHaveValue("Ana");
  await expect(page.getByText("No orders yet.")).toBeVisible();
  await expect(page.getByRole("button", { name: "Download orders (CSV)" })).toBeDisabled();
});
npx playwright test
Running 1 test using 1 worker

  ✓  1 [chromium] › tests/account.spec.ts:3:1 › Ana's account starts with no orders (152ms)

  1 passed (714ms)
What’s happening
  1. page.addInitScript registers a script that runs in every page of this test, before the page's own scripts. It writes {"username":"ana","name":"Ana"} to shop-user, so when the account page's script calls requireUser(), Ana is already signed in.
  2. The test goes straight to /practice/account: no form, no redirect, no 0.5 s sign-in delay.
  3. Four checks: the header names Ana, the display name defaults to her name, the order history is empty, and the download button is disabled because there's nothing to download.
  4. The trade-off: this is faster than a setup project, but it relies on how the shop stores its session (the key and the JSON shape). If the shop changed that, these tests would keep passing a login that real users can't do. The setup project signs in through the real form, so it fails when login breaks. Use the shortcut for extra users and roles, and keep at least one real sign-in in the run.
Your turn: smoke tests on a phone

Add a phone project to a config so that phones run only the @smoke tests, while desktop Chromium runs everything. Prove it with a run of one smoke test and one other test.

Show answer
playwright.config.ts
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
  testDir: "./tests",
  fullyParallel: true,
  use: { baseURL: "https://rohit-playwright.pages.dev" },
  projects: [
    { name: "chromium", use: { ...devices["Desktop Chrome"] } },
    // Phones get the smoke tests only: the journeys that must work everywhere, at a fraction of the cost.
    { name: "phone", use: { ...devices["Pixel 10"] }, grep: /@smoke/ },
  ],
});
tests/shop.spec.ts
import { test, expect } from "@playwright/test";

test.beforeEach(async ({ page }) => {
  await page.goto("/practice/");
  await page.getByLabel("Username").fill("rohit");
  await page.getByLabel("Password").fill("playwright");
  await page.getByRole("button", { name: "Sign in" }).click();
});

test("search finds products by name", { tag: "@smoke" }, async ({ page }) => {
  await page.getByLabel("Search products").fill("keyboard");
  await expect(page.getByRole("list", { name: "Products" }).getByRole("listitem")).toHaveCount(2);
});

test("sorting by price puts the cheapest first", async ({ page }) => {
  await page.getByLabel("Sort by").selectOption("Price: low to high");
  await expect(page.getByRole("list", { name: "Products" }).getByRole("heading").first()).toHaveText("Wireless Mouse");
});
npx playwright test
Running 3 tests using 3 workers

  ✓  3 [phone] › tests/shop.spec.ts:10:1 › search finds products by name @smoke (1.8s)
  ✓  2 [chromium] › tests/shop.spec.ts:10:1 › search finds products by name @smoke (1.8s)
  ✓  1 [chromium] › tests/shop.spec.ts:15:1 › sorting by price puts the cheapest first (1.9s)

  3 passed (2.5s)
What’s happening
  1. grep works on a project as well as on the command line: the phone project only runs tests whose title or tags match /@smoke/.
  2. So the run has 3 tests, not 4: both tests in chromium, and only the search test in phone. The sorting test never runs on the phone.
  3. devices["Pixel 10"] gives the phone project Chromium with a 360 px wide viewport, touch and a mobile user agent (Chapter 2). The shop's layout stacks at that width, and the role and label locators don't care.
  4. This is how teams keep device coverage affordable: the full suite on one desktop browser, a small smoke set on every device class. grepInvert on a project does the opposite (everything except a tag).

Written fresh, no doc. Tests were run with @playwright/test 1.65.1 (Chrome for Testing 159, Firefox 159, WebKit 27.2) against the Practice Shop at /practice/; facts come from playwright.dev, read 2026-11-24.

RohitDownloads · All chapters

Sync progress across devices

Type the same private phrase on your Mac and your phone, and your Learned ticks follow you between them — on every study site.

The phrase never leaves this device: only a fingerprint of it is sent, and the server stores a fingerprint of that. Anyone who knows the phrase could see or change your ticks, so pick something you don’t use elsewhere.

Sync is on in this browser.

Sync ID

This ID must be the same on every device. If another device shows a different one, its phrase is different (capital letters count): tap “Turn off here” on it and type the phrase again exactly.