Skip to main content

Jest

The Jest module runs Jest tests for JavaScript and TypeScript projects. Reach for it when Jest is already the test runner for the repo and you want those tests to become a Dagger check that runs in CI and Dagger Cloud, whether you're testing one app or package in a larger workspace or debugging which tests get discovered.

Official module: dagger/jest

Add it to your workspace

dagger install github.com/dagger/jest

Run the tests

dagger check           # run every check in the workspace
dagger check jest:test # run the Jest suite

jest:test installs dependencies and runs the Jest 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 Jest config.

Test options

The jest:test check runs with default options. Call the test function directly with dagger api call to override them:

  • files: limit the run to specific test files.
  • build: run the project's build script before testing.
  • useEnv: use the project's own Jest environment instead of the module's automatic OpenTelemetry environment.
  • flags: extra flags passed through to jest.

Use list to print the tests Jest discovers when test selection is unclear.

Configure it

List the current settings and their values with dagger settings jest, then set one with dagger settings jest <key> <value>. Settings are stored in dagger.toml under [modules.jest.settings]:

  • packageManager (default npm): the package manager used to install dependencies before testing. Set it to yarn or pnpm to match the project.
  • 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.jest.settings]
packageManager = "pnpm"
baseImageAddress = "node:22-alpine"

Working with other modules

Use this module when Jest is the test runner. Use Vitest instead for projects built around Vitest or Vite-first test workflows.