FORM FOLLOWS DOMAIN. DOMAIN COMES FIRST.NODE.JS / REACT
MODULE → SPEC → TEST

GENERATE.
THEN TEST.

@domain-first/project-structure

Prepare Vitest configuration and scripts, then generate unit-test skeletons with the modules you scaffold.

01Unit-test configuration
02Generated spec skeletons
03Tests and coverage scripts
01 / SETUP

Enable unit-test scaffolding.

Terminal
npx df-ps

Choose Add integration → Vitest. The preset creates a root-level vitest.config.ts and sets testingLibrary to vitest. If another testing library is configured, the CLI asks before replacing it.

Install missing dependencies with the commands printed by the CLI: vitest and @vitest/coverage-v8. The preset does not install packages or run tests.

02 / GENERATED TESTS

Create the module and its test.

With testingLibrary configured, supported generators create .spec.ts skeletons alongside the generated module. This includes supported domain models and services, use cases, commands, queries, ports and infrastructure/presentation services.

The initial tests cover construction or wiring. Fill them with business cases, assertions and failure scenarios. For repositories, commands, queries and ports, test templates reference wiring factories: enable wire or adapt construction to your own setup.

IMPLEMENTATIONS FOR TESTS

Repository, execution command/query and port generators can create separate test implementations. With environment-based wiring, tests use that variant when requested, otherwise the primary implementation.

03 / CONFIGURATION

Keep test tooling predictable.

The generated config resolves tsconfig paths and uses V8 coverage for bounded-contexts and shared under your rootFolder. Specs, infrastructure, REST presentation and wiring are excluded from coverage. The E2E specs folder is excluded from the unit-test config.

When handlers-next is declared, the config inlines it to resolve its Next headers import. The documented tsconfig-path resolution expects Vite 8 or newer. The preset adds /coverage/ to .gitignore and preserves unrelated package fields; script conflicts offer keep, replace or rename choices.

04 / RUN

Run the tests. Inspect coverage.

Terminal
npm run test
Terminal
npm run test:coverage

The generated scripts run Vitest with the dot reporter; the coverage command also enables coverage. These are unit-test tools. Browser end-to-end tests use the separate Playwright integration.

See Scaffolder ↗ for initial setup and the full generator catalog.