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:- Enable
devRunnerinsonamu.config.ts - Have the dev server running via
pnpm dev
sonamu.config.ts Configuration
api/src/sonamu.config.ts
Configuration Options
Basic Usage
Options
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.
Naite.t():
How It Works
pnpm sonamu test invokes the resident Vitest instance inside the dev server via an HTTP request.
- The CLI sends a POST request to the dev serverโs
/__test__/runendpoint. - The dev serverโs
DevVitestManagerruns the tests using the resident Vitest instance. - Results are returned as JSON, and the CLI prints a summary.
Comparison with pnpm test
When to use which?
- During development: Use
pnpm sonamu testfor 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
pnpm dev.
DevRunner not enabled
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