Complete worked example
typescript
import { test, expect } from "../support/test.js";
test("debounced search with controlled time", async ({page}) => {
await page.clock.install();
await page.goto("/");
const rows = page.getByRole("list", {name:"Matching roles"}).getByRole("listitem");
await expect(rows).toHaveCount(4);
await page.getByLabel("Search roles").fill("qa");
await page.clock.runFor(350);
await expect(rows).toHaveCount(2);
await expect(rows).toContainText(["QA Engineer", "QA Lead"]);
});- Reasoning
- Advancing the debounce is paired with an actual result assertion.