docs/versioned_docs/version-1.0-beta/modules/vitest.mdx
Official module: dagger/vitest
Install with dagger mod install github.com/dagger/vitest.
The Vitest module runs Vitest tests for JavaScript and TypeScript projects.
Use it when the project uses Vitest, especially Vite apps and modern frontend packages.
test: run the Vitest suite.list: show which tests Vitest sees.Install the module, then run its check:
dagger mod install github.com/dagger/vitest
dagger check # run every check in the workspace
dagger check vitest:test # run the Vitest suite
test installs dependencies and runs the Vitest suite over the workspace (excluding node_modules, dist, and build). It automatically registers an OpenTelemetry hook, so individual tests appear as spans in the Dagger TUI and Dagger Cloud without changing the project's Vitest config.
List the current settings and their values with dagger settings vitest, then set one with dagger settings vitest <key> <value>. Settings are stored in .dagger/config.toml under [modules.vitest.settings].
packageManager (default npm): the package manager used to install dependencies before testing. Set it to yarn or pnpm to match the project; with pnpm, the module enables Corepack automatically.baseImageAddress (default node:25-alpine): the Node base image tests run in. Pin it to the project's Node version, for example node:22-alpine.[modules.vitest.settings]
packageManager = "pnpm"
baseImageAddress = "node:22-alpine"
The vitest:test check runs with default options. Call the test function directly with dagger function call to override them:
files: limit the run to specific test files.build: run the project's build script before testing.flags: extra flags passed through to vitest.Use list to print the tests Vitest discovers when test selection is unclear.
Use this module when Vitest is the test runner. Use Jest instead for projects that already depend on Jest conventions and config.
Source repo: github.com/dagger/vitest