Skip to content

test(docs): add vitest browser tests for components - #756

Merged
AlexanderKaran merged 3 commits into
e18e:mainfrom
dreyfus92:test/docs-vitest
Nov 9, 2026
Merged

AlexanderKaran merged 3 commits into
e18e:mainfrom
dreyfus92:test/docs-vitest

Conversation

@dreyfus92

Copy link
Copy Markdown
Member

foundational setup for testing the docs components, as discussed with @AlexanderKaran. the goal is to have the base in place first and add tests incrementally from here, so anyone tweaking or adding a chart can drop a test next to it.

sets up vitest in browser mode for the shared components in packages/docs/src/components, so chart sizing and layout bugs get caught before review. each test renders the component with astro's container api, drops the html into headless chromium and runs its real client script, then checks what you'd actually see plus an axe pass.

StatsTable and ComparisonBarChart go first as examples to copy for the rest, with their test data in src/components/test/fixtures.ts.

things I hit while toying with this:

  • components have to be rendered on the node side (ssrLoadModule), importing an .astro in the browser runs its script during render.
  • a chart script only runs once per test file, so it's one chart per file and the focused scope is checked by mounting the chart twice.
  • src/lib tests stay on node:test for now, so test runs both.

checked that each test fails when its behavior breaks (focused filter, chart height, a missing framework, table scroll, empty links) and the built site is byte-identical to main. ci gets a step to install headless chromium.

@AlexanderKaran
AlexanderKaran merged commit 5c3698a into e18e:main Nov 9, 2026
95 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants