chore(test): replace nightwatch with playwright as the end-to-end framework #244

Sammanfogat
supernaut sammanfogade 2 incheckningar från work/174 in i main 2026-09-21 10:08:10 +00:00
Ägare

The end-to-end suite was one Nightwatch spec with three assertions, driving whatever Firefox happened to be on the developer's machine. It never ran in CI. Replaced with Playwright.

Two commits, deletion last, so a reviewer can stop after the first with both frameworks working. The issue's middle step (new specs) is deferred to its own issue, so it has no content here.

  • playwright.config.ts: port from E2E_PORT, default 4331 so pnpm dev can keep running. 127.0.0.1, not localhost, because on macOS localhost can resolve to ::1 while the server binds IPv4. locale: "sv-SE" and timezoneId: "Europe/Stockholm" pinned on the default context. The webServer block replaces the 77 lines of hand-rolled build, spawn, wait and teardown in scripts/e2e.mjs.
  • Projects chromium, webkit and mobile-safari on every run. mobile-safari reuses the WebKit binary and costs no extra download, which matters because on iOS every browser is WebKit and #158 reproduced there only. firefox opts in via E2E_FULL_MATRIX=true.
  • homepage.spec.ts ports the old spec and doubles it across sv and en, using role locators rather than the h1 CSS selector.
  • Deleted nightwatch.conf.js, scripts/e2e.mjs, src/test/e2e/homepage.js. Dropped nightwatch and geckodriver.
  • Cleaned eslint.config.mjs, pnpm-workspace.yaml allowBuilds (both entries removed, no playwright entry added, since @playwright/test has no postinstall browser download), the three ignore files, and added an src/test/e2e/** exclude to vitest.config.ts so the two runners cannot collide over a filename.
  • pre-push is narrowed to --project=chromium so the hook stays fast.
  • README and CONTRIBUTING now mention the suite. Neither did before.

Acceptance, all run:

  • pnpm test:e2e: 12 passed across chromium, webkit and mobile-safari.
  • E2E_FULL_MATRIX=true pnpm test:e2e: 16 passed, firefox included.
  • pnpm lint, pnpm check (0 errors, 0 warnings), pnpm test (361 passed).
  • grep -ril nightwatch over the working tree: no matches at all, lockfile included.
  • Fresh pnpm install --prod --frozen-lockfile in a scratch copy: no selenium, nightwatch or geckodriver anywhere under node_modules.

Two notes for the reviewer:

  • The dependencies versus devDependencies half of the motivation was already fixed on main before this branch started. The --prod check above is fresh evidence, not a claim inherited from the issue.
  • @axe-core/playwright is added per the issue's scope but nothing imports it yet. The accessibility specs that will are a separate issue. Drop it here if you would rather it arrived with its first consumer.

Out of scope and not done: wiring e2e into CI, baking browsers into the runner image, new specs.

Closes #174

The end-to-end suite was one Nightwatch spec with three assertions, driving whatever Firefox happened to be on the developer's machine. It never ran in CI. Replaced with Playwright. Two commits, deletion last, so a reviewer can stop after the first with both frameworks working. The issue's middle step (new specs) is deferred to its own issue, so it has no content here. - `playwright.config.ts`: port from `E2E_PORT`, default 4331 so `pnpm dev` can keep running. `127.0.0.1`, not `localhost`, because on macOS `localhost` can resolve to ::1 while the server binds IPv4. `locale: "sv-SE"` and `timezoneId: "Europe/Stockholm"` pinned on the default context. The `webServer` block replaces the 77 lines of hand-rolled build, spawn, wait and teardown in `scripts/e2e.mjs`. - Projects `chromium`, `webkit` and `mobile-safari` on every run. `mobile-safari` reuses the WebKit binary and costs no extra download, which matters because on iOS every browser is WebKit and #158 reproduced there only. `firefox` opts in via `E2E_FULL_MATRIX=true`. - `homepage.spec.ts` ports the old spec and doubles it across sv and en, using role locators rather than the `h1` CSS selector. - Deleted `nightwatch.conf.js`, `scripts/e2e.mjs`, `src/test/e2e/homepage.js`. Dropped `nightwatch` and `geckodriver`. - Cleaned `eslint.config.mjs`, `pnpm-workspace.yaml` `allowBuilds` (both entries removed, no `playwright` entry added, since `@playwright/test` has no postinstall browser download), the three ignore files, and added an `src/test/e2e/**` exclude to `vitest.config.ts` so the two runners cannot collide over a filename. - `pre-push` is narrowed to `--project=chromium` so the hook stays fast. - README and CONTRIBUTING now mention the suite. Neither did before. Acceptance, all run: - `pnpm test:e2e`: 12 passed across chromium, webkit and mobile-safari. - `E2E_FULL_MATRIX=true pnpm test:e2e`: 16 passed, firefox included. - `pnpm lint`, `pnpm check` (0 errors, 0 warnings), `pnpm test` (361 passed). - `grep -ril nightwatch` over the working tree: no matches at all, lockfile included. - Fresh `pnpm install --prod --frozen-lockfile` in a scratch copy: no selenium, nightwatch or geckodriver anywhere under `node_modules`. Two notes for the reviewer: - The `dependencies` versus `devDependencies` half of the motivation was already fixed on main before this branch started. The `--prod` check above is fresh evidence, not a claim inherited from the issue. - `@axe-core/playwright` is added per the issue's scope but nothing imports it yet. The accessibility specs that will are a separate issue. Drop it here if you would rather it arrived with its first consumer. Out of scope and not done: wiring e2e into CI, baking browsers into the runner image, new specs. Closes #174
supernaut lade till 2 incheckningar 2026-09-20 22:36:19 +00:00
Adds @playwright/test and @axe-core/playwright as devDependencies, a
playwright.config.ts (chromium, webkit, mobile-safari always; firefox behind
E2E_FULL_MATRIX), and homepage.spec.ts ported from src/test/e2e/homepage.js
with role locators, doubled across sv and en.

test:e2e now runs Playwright; test:e2e:ui and test:e2e:report are new. The
pre-push e2e job is narrowed to --project=chromium to stay fast. Nightwatch
stays in place for this commit so both frameworks work; it is removed next.
chore(test): remove Nightwatch
Alla kontroller lyckades
ci / ci (pull_request) Successful in 1m21s
62fe3d246a
Nightwatch is fully superseded by Playwright now. Drops nightwatch and
geckodriver, deletes nightwatch.conf.js, scripts/e2e.mjs and the old
homepage.js spec, and removes the now-dead eslint globals block and
pnpm-workspace.yaml allowBuilds entries.

A --prod install tree no longer pulls in nightwatch, geckodriver or
selenium-webdriver.
supernaut tvångsskickade work/174 från 62fe3d246a
Alla kontroller lyckades
ci / ci (pull_request) Successful in 1m21s
till 6c252c8b06
Alla kontroller lyckades
ci / ci (pull_request) Successful in 1m25s
2026-09-21 09:24:50 +00:00
Jämför
supernaut sammanfogade incheckning 80e9238d75 till main 2026-09-21 10:08:10 +00:00
supernaut tog bort grenen work/174 2026-09-21 10:08:10 +00:00
Logga in för att delta i denna konversation.
Inga granskare
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-web!244
Ingen beskrivning angiven.