@agentable/vitest-config
v0.4.2
Published
Shared Vitest presets for Fleet-family TypeScript libraries, DOM tests, Browser Mode, and packed artifacts.
Maintainers
Readme
@agentable/vitest-config
Shared Vitest 4.1 presets for source, DOM, browser, and packed-artifact tests.
Installation
pnpm add -D @agentable/vitest-config vitestTest a library
import { libraryPreset } from "@agentable/vitest-config";
import { defineConfig } from "vitest/config";
export default defineConfig({
test: { ...libraryPreset },
});libraryPreset uses Node.js and V8 coverage. Type-test collection and the test tsconfig remain
owned by the consumer, which can run vitest run --typecheck.only with its real project config.
Test DOM behavior
Install jsdom, then use domPreset for React hooks, components, or other lightweight DOM behavior.
pnpm add -D jsdomimport { domPreset } from "@agentable/vitest-config";
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
...domPreset,
setupFiles: ["./src/test/setup.ts"],
},
});Test in a real browser
Install the Playwright provider and pass the provider plus browser instances to browserPreset.
pnpm add -D @vitest/browser-playwright playwright
pnpm exec playwright install chromiumimport { browserPreset } from "@agentable/vitest-config";
import { playwright } from "@vitest/browser-playwright";
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
...browserPreset({
provider: playwright(),
instances: [{ browser: "chromium" }],
}),
include: ["src/**/*.browser.test.ts"],
},
});Use --browser.headless in CI. Browser lifecycle and isolation remain owned by Vitest and the
provider.
Test packed artifacts
Use artifactPreset in a workspace that installs and imports final tarballs. Do not add source
aliases or source coverage to this project.
import { artifactPreset } from "@agentable/vitest-config";
import { defineConfig } from "vitest/config";
export default defineConfig({
test: {
...artifactPreset,
include: ["**/*.artifact.test.ts"],
},
});Presets
| Preset | Environment | Project name | Coverage |
| ------------------------ | ------------ | ------------ | -------- |
| libraryPreset | Node.js | Consumer | V8 |
| domPreset | jsdom | Consumer | V8 |
| browserPreset(options) | Browser Mode | Consumer | V8 |
| artifactPreset | Node.js | artifact | Disabled |
Presets keep Vitest's explicit-import, parallel, reporter, timeout, and mock-lifecycle defaults.
License
This project is licensed under the MIT License - see the LICENSE file for details.
