Vitest
Official module: dagger/vitest
Install with dagger mod install github.com/dagger/vitest.
What It Is​
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.
Use It For​
- Run Vitest as a workspace check.
- Validate frontend packages and libraries.
- List discovered tests when test selection is unclear.
Main Workflows​
test: run the Vitest suite.list: show which tests Vitest sees.
How to Use It​
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.
Settings​
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(defaultnpm): the package manager used to install dependencies before testing. Set it toyarnorpnpmto match the project; withpnpm, the module enables Corepack automatically.baseImageAddress(defaultnode:25-alpine): the Node base image tests run in. Pin it to the project's Node version, for examplenode:22-alpine.
[modules.vitest.settings]
packageManager = "pnpm"
baseImageAddress = "node:22-alpine"
Test options​
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 tovitest.
Use list to print the tests Vitest discovers when test selection is unclear.
Workspace Fit​
Use this module when Vitest is the test runner. Use Jest instead for projects that already depend on Jest conventions and config.
Source​
Source repo: github.com/dagger/vitest