Repository navigation
test(a11y): run the audit CLI fixtures on an OS-assigned port - #7765
Conversation
The accessibility-audit CLI fixtures started the CLI's server on 40000 + (pid % 10000), inside Linux's ephemeral port range, so another process's socket could already hold the port and the CLI died with EADDRINUSE before reaching the behavior under test. accessibility-audit.js now accepts --port 0 and builds its story URLs and expected origin from the port its server actually holds. The fixtures pass --port 0, and the mock browser fetches the URL it is sent, so a fixture passes only when the audit opens the bound port.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression40 of 486 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 20 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
This looks ready to merge. The fixtures now bind an OS-assigned port and the audit addresses the port its server actually holds, so a busy machine can no longer fail them with EADDRINUSE, while every CI invocation keeps the default port 6007. The fetching goto mock also makes the fixtures fail if the audit ever opens a different port. Nothing else is needed from you.
[Automated review]
Maintainer impact
.github/scripts/accessibility-audit.integration.test.mjsstarts the audit CLI's static server on40000 + (pid % 10000), one port per fixture. That range sits inside Linux's ephemeral port range (32768–60999 by default), where the kernel picks source ports for outgoing connections, so on a busy machine another process can already hold the chosen port. The CLI then exits withlisten EADDRINUSEbefore it reaches the behavior under test, and the suite fails with no change to the code it covers. The fullpnpm testruns reported in #7651 and #7694 both hit this, and both passed when the file was rerun alone.Intended invariant
The fixtures exercise the CLI's readiness, routing and report paths. Which port its server binds is incidental, so a fixture run should fail only for a defect in those paths.
Change
accessibility-audit.jsaccepts--port 0, the usual way to ask the OS for a free port. It builds the story URLs and the expected origin from the port its server actually holds (server.address().port). Every other--portvalue behaves as before, and the default stays 6007.--port 0and drop the PID-derived counter.gotonow fetches the URL it receives, so a fixture passes only when the audit opens the port its server holds. A new case asserts that the server reports a real port.No workflow passes
--port, so CI audits are unchanged.Evidence
Error: listen EADDRINUSE: address already in use :::43064ataccessibility-audit.js:195, in a full local run beside parallel builds. The two affected cases pass alone. This test file run against main's script fails 11 of 11 cases withInvalid --port value: 0.fetch failed).Scope
Testing
pnpm exec vitest run --project node .github/scripts/accessibility-audit.integration.test.mjs: 11/11 pass (on main's script: 11/11 fail).pnpm exec vitest run --project node .github/scripts: 64 files, 1,150 tests pass.pnpm -F @astryxdesign/core typecheck, ESLint on both files,pnpm check:repo: pass.