chore(test): replace Nightwatch with Playwright as the end-to-end framework #174
Etiketter
Inga etiketter
area/backups
area/ci
area/control-panel
area/identity
area/infra
area/observability
area/payments
area/security
area/storage
area/web
blocked
needs-info
needs-triage
ready-for-implementation
type
bug
type
chore
type
docs
type
epic
type
feature
type
task
wontfix
Ingen milstolpe
Inget projekt
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Inget förfallodatum satt.
Beroenden
Inga beroenden satta
Referens
bitborg/bitborg-web#174
Läser in…
Hänvisa till i nytt ärende
Ingen beskrivning angiven.
Ta bort grenen "%!s()"
Borttagning av en gren är permanent. Även om den borttagna grenen kan fortsätta existera en kort tid innan den faktiskt tas bort, kan det INTE ångras i de flesta fall. Vill du fortsätta?
The end-to-end suite is one Nightwatch spec with three assertions, copied from the Astro guide,
driving whatever Firefox happens to be installed on the developer's machine. It has never run in
CI — it is enforced only by the
pre-pushhook inlefthook.json. Replace it with Playwright.Three things motivate the swap beyond taste:
nightwatchis declared independencies, notdevDependencies, and the Containerfile runspnpm install --prodin both stages — so the container serving www.gitborg.se ships a WebDriverclient and its closure (selenium-webdriver 18 MB, nightwatch 3.3 MB, axe-core 2.9 MB, and their
transitive deps). None of it has a runtime purpose.
iOS every browser is WebKit. geckodriver cannot reach that engine; Playwright can.
scripts/e2e.mjsis 77 lines of hand-rolled build / spawn / wait-for-ready / teardown thatPlaywright's
webServerconfig block replaces with about eight.Scope
@playwright/testand@axe-core/playwrightto devDependencies.playwright.config.ts. Keep the existing conventions: port fromE2E_PORT, default 4331(not the dev server's 4321),
127.0.0.1rather thanlocalhost(on macOSlocalhostcanresolve to ::1 while the server binds IPv4). Set
locale: "sv-SE"andtimezoneId: "Europe/Stockholm"on the default context — the site is Swedish-first, and pinningthem stops a UTC runner and a CEST laptop disagreeing.
chromium,webkit, andmobile-safari(devices["iPhone 15"], which reuses theWebKit binary and costs no extra download) on every run;
firefoxonly whenE2E_FULL_MATRIX=true. Firefox is what Nightwatch drove, so it is kept, but no Gecko-only defecthas ever been found here and it is a 108 MB download — it belongs on the
push: mainrun ratherthan on every pull request.
src/test/e2e/homepage.jstohomepage.spec.ts, doubled acrosssvanden. Use rolelocators (
getByRole("heading", { level: 1 })) rather than the"h1"CSS selector.nightwatch.conf.js,scripts/e2e.mjs,src/test/e2e/homepage.js; dropnightwatchfrom
dependenciesandgeckodriverfrom devDependencies.eslint.config.mjsand thenightwatch.conf.jsentry from the node-globals block below it. Specs are TypeScript with real imports, so no globals
injection is needed.
@nightwatch/nightwatch-inspectorandgeckodriverentries frompnpm-workspace.yaml'sallowBuilds. Do not add aplaywrightentry —@playwright/testhas no postinstall browser download, which is a supply-chain improvement over geckodriver's.
tests_output/→playwright-report/+test-results/in.gitignore,.prettierignoreand.stylelintignore(and fix the stale "nightwatch" comment in.gitignore).src/test/e2e/**invitest.config.tsso the two runners can nevercollide over a filename.
test:e2e→playwright test; addtest:e2e:uiandtest:e2e:report.pre-pushe2e job inlefthook.jsonto--project=chromiumso the hook stays fast.README.md/CONTRIBUTING.md— neither mentions end-to-end tests today.Sequencing
Commit in three steps, deletion last, so a reviewer can stop after step 1 with both frameworks
working: (1) add Playwright alongside and port the spec; (2) add the new specs (separate issue);
(3) remove Nightwatch.
Out of scope
Wiring e2e into CI, and baking browsers into the runner image — both are separate issues, and the
image must be baked before CI depends on it.
Acceptance
pnpm test:e2epasses on chromium, webkit and mobile-safariE2E_FULL_MATRIX=true pnpm test:e2ealso passes on firefoxpnpm lint,pnpm check,pnpm testpassgrep -ri nightwatchover the working tree returns nothing but the lockfile's unrelatedvitest peer entries
--prodinstall tree no longer containsselenium-webdriver