API Reference / @gtkx/vitest / default
Function: default()
default(
options?):Plugin
Defined in: packages/vitest/src/index.ts:56
Vitest plugin that runs each test worker against its own isolated headless Wayland display. It configures the forks pool, injects the worker preload and setup files, and sets the environment needed for headless GTK4 rendering.
Each worker's compositor, session bus, and private runtime directory are torn down when the worker exits normally, along with processes still running in that runtime, such as GTK's sandboxed image loaders. Creating the plugin reaps orphaned display helpers and stale gtkx-xdg-* runtime directories left behind by earlier runs, which gtkx cleanup also does on demand.
Test files always run in isolated workers: Vitest fails to start when a project sets isolate: false, because GTKX shuts each worker's runtime down after its file.
When Sway or dbus-daemon is missing from PATH, Vitest fails to start, before any worker launches, with an error naming each missing tool. Loading the configuration without starting Vitest does not require them.
Parameters
options?
PluginOptions = {}
Plugin options; the headless display size is forwarded to each worker.
Returns
Plugin
A Vitest config plugin.