Browser testing
Deprecated. Browser QA has one owner: use game-harness's
defineBrowserTestConfig(game-harness/vitest), which carries the renderer profiles, the mute, multi-instance viewports and the browser server's address; in place ofdefaultBrowserLaunchArgs, itscreateChromiumLaunchProfile(game-harness/chromium).defineBrowserTestanddefaultBrowserLaunchArgsstay for existing consumers and are removed in the next major.defineUnitTeststays here.
defineBrowserTest
Returns { include, optimizeDeps, fileParallelism, browser } to spread into a Vitest config. It
supports Vitest 4 and Vitest 5 and builds the Playwright provider itself.
- Headed only.
browser.headlessisfalse. Passing aheadlessoption throws aTypeError, and so does any--headlessor--headless=...entry inextraLaunchArgs. A non-visual diagnostic belongs in a separate config. - Muted at the process level.
--mute-audiois the first launch argument, insideprovider.options.launchOptions.args. There is no detached launch-argument array to forget. The consumer is still responsible for activating and asserting a non-persistent runtime mute route in the game, without touching the player's saved audio preference. - GPU-friendly. The defaults enable the GPU path through ANGLE and SwiftShader so WebGL tests run on machines without a hardware GPU.
- One browser.
fileParallelismdefaults tofalsebecause real-Chromium tests share one instance. In Vitest 5 it is the top-leveltest.fileParallelism; spread it there. - A stable module graph.
threeis pre-bundled by default (includeThree: true) so Vite's dep-optimizer does not re-bundle mid-run and create a second React instance. SetincludeThree: falsefor Pixi, canvas and DOM-only games, and list other modules inoptimizeDepsInclude.
defineUnitTest
Returns { include, exclude, environment, environmentOptions? } for pure-logic tests. The default
environment is jsdom, with the origin set to http://localhost:3000 because jsdom exposes
localStorage and sessionStorage only on a real origin. Pass environment: "node" for code that
never touches the DOM.
defaultBrowserLaunchArgs
Returns the launch arguments defineBrowserTest uses, with your extras appended. It rejects hidden
headless flags too.
Running
pnpm exec playwright install --with-deps --no-shell chromium
xvfb-run -a pnpm exec vitest run --config vitest.browser.config.ts # Linux without a display