Files
skills/docs/devtools/tooling/test-vite
2026-05-29 08:20:56 +01:00
..
2026-05-29 08:20:56 +01:00
2026-05-29 08:20:56 +01:00

@suaveplan/test-vite - Vite + Vitest configuration factories and validators: createViteLibraryConfig/createViteAppConfig/createVitestConfig/createVitestBrowserConfig, browser-environment shims, tree-shake validator, bundle-size snapshot, port allocator, HMR tester, custom matchers, TEST_VITE_CODES error registry, and OTel self-telemetry.

Vite + Vitest configuration factories and validators for Suaveplan: createViteLibraryConfig, createViteAppConfig, createVitestConfig, createVitestBrowserConfig, setupBrowserEnvironment, tree-shake validator, bundle-size snapshot, port allocator, HMR tester, custom matchers, TEST_VITE_CODES error registry, and OTel self-telemetry.

Documentation tree

  • browser-environment — setupBrowserEnvironment installs the DOM and Web-platform shims that suaveplan browser packages depend on when running…
    • browser-environment — setupBrowserEnvironment installs the DOM and Web-platform shims that suaveplan browser packages depend on when running…
  • bundle-size-snapshot — snapshotBundleSize compares the byte size of an emitted bundle against a previously-recorded snapshot file and enforc…
    • bundle-size-snapshot — snapshotBundleSize compares the byte size of an emitted bundle against a previously-recorded snapshot file and enforc…
  • error-codes — error-codes exports the canonical stable error-code registry used by every other module in @suaveplan/test-vite. Th…
    • error-codes — error-codes exports the canonical stable error-code registry used by every other module in @suaveplan/test-vite. Th…
  • hmr-tester — withHMR round-trips a single Vite HMR edit through an injectable HmrServerLike adapter and asserts that the expecte…
    • hmr-tester — withHMR round-trips a single Vite HMR edit through an injectable HmrServerLike adapter and asserts that the expecte…
  • matchers — createMatchers returns a bundle of typed expect.extend matchers used across suaveplan browser-tier test suites. The m…
    • matchers — createMatchers returns a bundle of typed expect.extend matchers used across suaveplan browser-tier test suites. The m…
  • port-allocator — createPortAllocator builds a deterministic port allocator over a contiguous TCP range backed by an injectable store.…
    • port-allocator — createPortAllocator builds a deterministic port allocator over a contiguous TCP range backed by an injectable store.…
  • telemetry — telemetry registers the OTel meter for @suaveplan/test-vite and exposes the counters and histogram that every other…
    • telemetry — telemetry registers the OTel meter for @suaveplan/test-vite and exposes the counters and histogram that every other…
  • tree-shake-validator — verifyTreeShake reads a built bundle and asserts that its set of exported symbols matches the caller-supplied allow-l…
    • tree-shake-validator — verifyTreeShake reads a built bundle and asserts that its set of exported symbols matches the caller-supplied allow-l…
  • vite-app-config — createViteAppConfig builds a Vite UserConfig tailored for consumer applications rather than library packages. It de…
    • vite-app-config — createViteAppConfig builds a Vite UserConfig tailored for consumer applications rather than library packages. It de…
  • vite-library-config — createViteLibraryConfig builds an opinionated Vite UserConfig suitable for any @suaveplan/* library package. It e…
    • vite-library-config — createViteLibraryConfig builds an opinionated Vite UserConfig suitable for any @suaveplan/* library package. It e…
  • vitest-browser-config — createVitestBrowserConfig builds a Vitest configuration that drives tests through Playwright in real browsers. The fa…
    • vitest-browser-config — createVitestBrowserConfig builds a Vitest configuration that drives tests through Playwright in real browsers. The fa…
  • vitest-config — createVitestConfig returns a WSL2-safe Vitest configuration with the suaveplan enterprise contract baked in. The factor…
    • vitest-config — createVitestConfig returns a WSL2-safe Vitest configuration with the suaveplan enterprise contract baked in. The factor…

Why

Every browser-tier Suaveplan package needs the same Vite library build + WSL2-safe Vitest configuration. Inlining that copy across hundreds of packages is brittle — when the project learns a new safety default (Istanbul, pool: 'forks', fileParallelism, the external baseline), each package has to be updated by hand. @suaveplan/test-vite owns those factories in one place.

Features

  • Opinionated Vite library build (createViteLibraryConfig) with preserveModules, dts emission, and the external baseline (/^@suaveplan\//, /^node:/, 'tslib').
  • Vite consumer-app config (createViteAppConfig) with hashed assets and envPrefix.
  • WSL2-safe Vitest config (createVitestConfig) — pool: 'forks', Istanbul provider, 100/100/100/100 thresholds.
  • Browser-mode Vitest config (createVitestBrowserConfig) driven by Playwright.
  • DOM shims (setupBrowserEnvironment) — idempotent installer for localStorage, matchMedia, ResizeObserver, IntersectionObserver, crypto.
  • Tree-shake validator (verifyTreeShake) — guard the exported-symbol set.
  • Bundle-size snapshot (snapshotBundleSize) — track build-size drift with tolerance.
  • Port allocator (createPortAllocator) — coordinate parallel servers on WSL2.
  • HMR tester (withHMR) — round-trip a Vite HMR cycle in tests.
  • Typed expect.extend matchers — toBeAccessibleNode, toMatchDataURL, toHaveValidCSSVars.
  • Stable TEST_VITE_CODES registry + TestViteError.
  • OTel self-telemetry — counters + histogram, no-op when no provider is registered.

Install

import { createViteLibraryConfig } from "@suaveplan/test-vite/vite-library-config";
import { createVitestConfig } from "@suaveplan/test-vite/vitest-config";

Every feature module is its own subpath export for tree-shake friendliness.

License

MIT