Skip to content

Function: defineXmBrowserConfig()

API / @xmachines/shared / vitest / defineXmBrowserConfig

function defineXmBrowserConfig(importMetaUrl, overrides, options?): UserConfig;

Defined in: vitest.ts:167

Create a Vitest browser-mode config with XMachines workspace defaults.

Composes defineXmVitestConfig (so alias resolution, setup-file normalization/injection, and the required deep excludes all apply) and bakes in the browser boilerplate shared by every browser test project:

  • cacheDir from xmCacheDir(importMetaUrl, test.name) and resolve from xmResolve(importMetaUrl) (standalone configs only).
  • optimizeDeps from xmOptimizeDeps(options.optimizeDeps).
  • test.include: ["test/browser/**/*.browser.test.ts"] and test.exclude: ["**/node_modules/**", "**/dist/**"] defaults.
  • test.fileParallelism: false.
  • Headless Playwright Chromium via test.browser.

Everything in overrides wins over these defaults: test.include, test.exclude, and test.setupFiles replace the defaults when provided, and test.browser entries (e.g. an api port) are merged on top of the Playwright defaults. Plugins stay per-package arguments (plugins: [vue()]).

Parameters

ParameterTypeDescription
importMetaUrlstringPass import.meta.url from the calling config file.
overridesUserConfigPackage/project-specific Vitest config overrides. overrides.test.name is required — it names the project and keys the shared Vite cache directory.
optionsXmBrowserConfigOptionsBrowser-specific knobs, see XmBrowserConfigOptions.

Returns

UserConfig

Merged Vitest configuration object.