Файли
openidea/fixtures/playwright-app/tests/checkout.spec.ts
T
LU XIANGRUIтаwildcatDownstairs 9b4ee2a6ff feat(run): run Playwright tests with a test tree and Rerun Failed Tests (#5169)
A Playwright project had no test tree and no Rerun Failed Tests: its output went through the Jest / Vitest parser, single tests ran with Jest's `-t`, and projects without a `test` script weren't detected at all.

- Detection: a `package.json` script that runs `playwright test` is a test configuration and records `testRunner: "playwright"` (new optional `RunExtras.test_runner`, `test-runner` in `run.toml`); a package with a `playwright.config.*` that no script runs gets `npx playwright test`.
- Test tree: test runs add `--reporter=list` unless a reporter is named, parsed into file › [project] › describe chain › test with status, duration, location and failure details.
- Gutter: `test.describe` blocks and `fixme` / `fail` / `serial` tests get run / debug icons and run by declaration line (`file:line`); in a project with Playwright and another runner, specs run on Playwright's configuration and other tests on the other runner's.
- Rerun Failed Tests / run selected tests: the files plus `--grep` on the describe chain and title, with `--project` when the run named projects.

New fixture `fixtures/playwright-app`; `smoke/run.test.ts` runs it after `ts-app`.

Co-authored-by: wildcatDownstairs <[email protected]>
2026-11-22 14:30:06 +08:00

37 рядки
1013 B
TypeScript

import { expect, test } from "@playwright/test";
import { applyCoupon, shipping, subtotal, type Line } from "../src/checkout.ts";
const mug: Line = { sku: "mug", price: 12, quantity: 2 };
const lamp: Line = { sku: "lamp", price: 40, quantity: 1 };
test.describe("checkout", () => {
test("adds up the lines", () => {
expect(subtotal([mug, lamp])).toBe(64);
});
test.describe("shipping", () => {
test("is free from 50", () => {
expect(shipping([mug, lamp])).toBe(0);
});
test("is a flat rate below 50", () => {
expect(shipping([mug])).toBe(4.99);
});
});
test("intentionally fails (set OPENIDEA_FAIL=1)", () => {
test.skip(!process.env.OPENIDEA_FAIL, "set OPENIDEA_FAIL=1");
expect(shipping([lamp])).toBe(0);
});
});
test.describe("coupons", () => {
test("halves the total", () => {
expect(applyCoupon(64, "HALF")).toBe(32);
});
test("rejects unknown codes", () => {
expect(() => applyCoupon(64, "NOPE")).toThrow("unknown coupon");
});
});