Skip to main content
The pnpm sonamu test command runs tests through the Vitest instance hosted in the dev server. Since the dev server reuses already-loaded modules, you get faster feedback compared to pnpm test, which initializes everything from scratch each time.

Prerequisites

Two things are required to use this command:
  1. Enable devRunner in sonamu.config.ts
  2. Have the dev server running via pnpm dev

sonamu.config.ts Configuration

api/src/sonamu.config.ts

Configuration Options

Basic Usage

Options

You can specify multiple file paths:

Trace Output

Use the --traces (-t) option to display trace information collected via Naite.t() during test execution. Each trace includes its key, source location, and value.
You can record traces in your test or model code using Naite.t():

How It Works

pnpm sonamu test invokes the resident Vitest instance inside the dev server via an HTTP request.
  1. The CLI sends a POST request to the dev serverโ€™s /__test__/run endpoint.
  2. The dev serverโ€™s DevVitestManager runs the tests using the resident Vitest instance.
  3. Results are returned as JSON, and the CLI prints a summary.

Comparison with pnpm test

When to use which?
  • During development: Use pnpm sonamu test for quick feedback. You can modify code and immediately run tests.
  • CI/CD: Use pnpm test. It runs the full test suite in an isolated environment.

Status Check

You can check DevRunner status using the --status flag in the CLI or by sending a request directly to the HTTP endpoint:

Troubleshooting

Cannot connect to dev server

Solution: Start the dev server first with pnpm dev.

DevRunner not enabled

Solution: Set test.devRunner.enabled to true in sonamu.config.ts and restart the dev server.

Next Steps

Test Structure

Learn about the Vitest-based test system

dev

Learn more about the development server