Skip to content

usm/gen-testspecs ​

Vitest test specs generator — produces per-feature and aggregated Vitest test files from flows[] and tests[] definitions.

Why this exists ​

Feature .usm files define flows and tests in a structured format. The test specs generator converts these into executable Vitest test files, producing both per-feature specs and aggregated test bundles per app.

How it works ​

Generate Vitest test specs (gen-test-specs) ​

Convert flows and tests from .usm into Vitest describe/it blocks

  1. Parse — all feature .usm files with tests and flows
  2. Generate — per-feature .test.ts files with describe blocks
  3. Generate — aggregated test bundles per app
  4. Submit — write to tests/auto-generated/

Flow Diagrams ​

mermaid
sequenceDiagram
    participant User
    participant Browser
    participant Server

    User->>Browser: parse all feature .usm files with tests and flows
    User->>Browser: generate per-feature .test.ts files with describe blocks
    User->>Browser: generate aggregated test bundles per app
    User->>Browser: submit write to tests/auto-generated/

Guarantees ​

test-specs-runnable ​

Generated test specs must be syntactically valid Vitest files

Acceptance criteria:

  • [ ] Each flow maps to a describe block
  • [ ] Each test maps to an it block with setup and expect
  • [ ] Aggregated specs import per-feature files

vitest-specs-from-flows-tests ​

Test specs are a pure, collision-free function of the .usm inputs

Acceptance criteria:

  • [ ] One output spec file per feature $id
  • [ ] Source path resolution is exact $id parsing, not substring matching (issue #37 class)
  • [ ] Two features must never target the same output path
  • [ ] Generated specs are valid Vitest files

Test specifications ​

test-specs-per-feature ​

Given:

  • feature_with_tests: true

Then:

  • assertion: .test.ts file generated with valid syntax
  • assertion: Contains describe and it blocks

test-specs-aggregated ​

Given:

  • multiple_features: true

Then:

  • assertion: Aggregated test file imports per-feature specs

Implementation ​

  • Primary: src/generators/testSpecs.ts
  • Test code status: none

See Also ​

  • usm/cli-generate