Skip to content

feat(test-utils): Add vitest infrastructure with browser commands#10064

Open
chrisgervang wants to merge 8 commits intochr/test-utils-vitest-entryfrom
chr/test-utils-vitest-entry-v1
Open

feat(test-utils): Add vitest infrastructure with browser commands#10064
chrisgervang wants to merge 8 commits intochr/test-utils-vitest-entryfrom
chr/test-utils-vitest-entry-v1

Conversation

@chrisgervang
Copy link
Copy Markdown
Collaborator

@chrisgervang chrisgervang commented Mar 4, 2026

Summary

Adds comprehensive vitest infrastructure for multi-environment testing: Node.js, scripts, headless browser (JSDOM), real browser (Playwright), and visual regression testing.

Change List

  • vitest.config.ts: Complete multi-project configuration (node, scripts, headless, browser, render) with Playwright browser commands, dependency optimization, and asset serving
  • test/setup/vitest-node-setup.ts: Node environment setup with JSDOM polyfills and typed array equality tester for tape backward compatibility
  • test/setup/vitest-browser-setup.ts: Browser environment initialization with typed array tester and vitest browser command bridge
  • test/setup/browser-commands.ts: Custom vitest browser commands (captureAndDiffScreen for visual regression, emulateInput for interactions, isHeadless for environment detection)
  • test/setup/vitest-browser-commands.d.ts: TypeScript type declarations for browser commands and interfaces
  • package.json: Added postinstall script, new test scripts (test-headless, test-render, test-browser, test-ci), and aligned dependencies

Closes #


Note

Medium Risk
Touches core test/CI wiring by introducing multi-project Vitest configuration, Playwright installation on postinstall, and new screenshot/input browser command plumbing; this may cause CI flakiness or platform-specific failures (native sharp, golden image diffs).

Overview
Adds a multi-project Vitest configuration (node, scripts, headless, browser, render) with shared aliases, dependency pre-bundling, static asset serving, and optional V8 coverage for browser runs.

Introduces custom Vitest browser commands (captureAndDiffScreen, emulateInput, isHeadless) to replace @probe.gl/test-utils’s window.browserTestDriver_* APIs, including Playwright screenshot capture + pixelmatch/sharp diffing and iframe-aware input emulation.

Updates test bootstrapping via new vitest-node-setup and vitest-browser-setup (typed-array equality for tape compatibility, JSDOM polyfills for node, and a bridge wiring window.browserTestDriver_* to vitest/browser commands), and extends package.json with Playwright install + new focused test scripts and dependencies.

Written by Cursor Bugbot for commit 908731d. This will update automatically on new commits. Configure here.

@chrisgervang chrisgervang force-pushed the chr/test-utils-vitest-entry-v1 branch from 377c434 to 6405bc2 Compare March 4, 2026 22:25
@chrisgervang chrisgervang force-pushed the chr/test-utils-vitest-entry-v1 branch from f32303d to b3812bc Compare March 4, 2026 22:50
@chrisgervang chrisgervang force-pushed the chr/test-utils-vitest-entry branch from c6b6e8c to 63446d4 Compare March 4, 2026 22:52
@chrisgervang chrisgervang force-pushed the chr/test-utils-vitest-entry-v1 branch from b3812bc to b49edc7 Compare March 4, 2026 22:57
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@chrisgervang chrisgervang force-pushed the chr/test-utils-vitest-entry-v1 branch from b30d4db to 41e35a3 Compare March 6, 2026 22:43
@chrisgervang chrisgervang force-pushed the chr/test-utils-vitest-entry branch from 9211999 to c337c4e Compare March 9, 2026 18:07
chrisgervang and others added 6 commits March 9, 2026 12:15
Add vitest configuration and setup files for running tests:
- vitest.config.ts with node/scripts/headless/browser/render projects
- test/setup/vitest-node-setup.ts with JSDOM polyfills and typed array equality
- test/setup/vitest-browser-setup.ts with browser test driver bridge
- test/setup/browser-commands.ts with captureAndDiffScreen and emulateInput
- test/setup/vitest-browser-commands.d.ts with TypeScript declarations

Add package.json scripts: test-headless, test-render, test-browser, test-ci
Add devDependencies: @vitest/browser-playwright, @vitest/coverage-v8,
  @probe.gl/test-utils, pixelmatch, playwright, pngjs, sharp

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reduces code duplication between vitest-node-setup.ts and
vitest-browser-setup.ts by extracting to typed-array-equality.ts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change import from @vitest/browser/context to vitest/browser to fix
deprecation warning in newer vitest versions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… browser project

- Add vitest/browser to optimizeDepsConfig to prevent flaky tests
- Remove test/render/**/*.spec.ts from browser project (use render project instead)
- Add clarifying comments throughout config

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use node project which includes test/smoke/**/*.spec.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chrisgervang chrisgervang force-pushed the chr/test-utils-vitest-entry-v1 branch from 1e3b04e to eb67e83 Compare March 9, 2026 19:15
chrisgervang and others added 2 commits March 9, 2026 13:16
The polyfills package has .node extension files that vitest/ESM cannot
resolve. JSDOM already provides the browser APIs that polyfills would
provide (TextEncoder, TextDecoder, atob, btoa, etc.)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tests both node and headless browser environments in smoke test
to verify vitest infrastructure works end-to-end.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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