Skip to main content

/qa-test-generate

Produce runnable Vitest unit tests and Playwright E2E specs from BDD test cases and scaffold code.


Overview

Transforms BDD/Gherkin test cases (from /qa-test-cases) into runnable test files using Vitest for unit/integration tests and Playwright for E2E tests. Generates test data factories, MSW mock handlers, page objects, and CI configuration. Uses tag-based routing to map scenarios to the correct test layer.


Usage

/qa-test-generate
/qa-test-generate qa-test-cases backend-scaffold
ArgumentRequiredDescription
qa-test-casesYesPath to BDD/Gherkin test cases output
backend-scaffold or frontend-scaffoldYesPath to scaffold output
backend-api-contractNoOpenAPI YAML for MSW handler generation
backend-service-implementNoService files for deeper unit tests
--from-mutantsNoPath to survivors JSON from /qa-test-mutate

When run without arguments, launches an interactive wizard.


What It Produces

Files at $JAAN_OUTPUTS_DIR/qa/test-generate/{id}-{slug}/:

FileContent
{id}-{slug}.mdTest generation guide with coverage map
*.unit.test.tsVitest unit tests with jest-cucumber BDD binding
*.integration.test.tsAPI/service integration tests
*.e2e.spec.tsPlaywright E2E tests with playwright-bdd
*.factory.tsTest data factories (Fishery + zod-mock)
*.handlers.tsMSW mock handlers from OpenAPI
*.page.tsPage objects for Playwright
vitest.config.tsVitest workspace configuration
playwright.config.tsPlaywright BDD configuration

What It Asks

QuestionWhenWhy
Test layer scopeAlwaysUnit / integration / E2E / all
BDD binding styleNot detectedjest-cucumber / playwright-bdd
Mock strategyAPI testsMSW / manual mocks / both
CI runnerNot in tech.mdGitHub Actions / GitLab CI

Tag Routing

Maps Gherkin tags to test layers:

TagLayerFramework
@unitUnit testVitest + jest-cucumber
@integrationIntegration testVitest + supertest
@e2eE2E testPlaywright + playwright-bdd
@apiAPI testVitest + MSW

Workflow Chain

/qa-test-cases + /backend-scaffold --> /qa-test-generate

Example

Input:

/qa-test-generate path/to/test-cases path/to/backend-scaffold

Output:

jaan-to/outputs/qa/test-generate/01-user-auth/
├── 01-user-auth.md
├── user-auth.unit.test.ts
├── user-auth.integration.test.ts
├── user-auth.e2e.spec.ts
├── user-auth.factory.ts
├── user-auth.handlers.ts
├── user-auth.page.ts
├── vitest.config.ts
└── playwright.config.ts

Mutation-Guided Mode

Generate targeted tests for surviving mutants identified by /qa-test-mutate:

/qa-test-generate --from-mutants path/to/survivors.json

The --from-mutants flag reads a survivors JSON file (schema v1.0) produced by /qa-test-mutate. For each surviving mutant, the skill generates a targeted test that specifically kills that mutant, improving overall mutation score without redundant test bloat.


Pyramid Validation

Test generation includes testing pyramid validation to ensure the generated test distribution follows best practices:

  • More unit tests than integration tests
  • More integration tests than E2E tests

If the generated output violates pyramid proportions, the skill emits a warning and suggests rebalancing before finalizing.


Tips

  • Run /qa-test-cases first to generate BDD scenarios
  • Provide OpenAPI contract for automatic MSW handler generation
  • Use tag routing to control which test layers are generated
  • Copy generated configs to your project and adjust paths


Technical Details

  • Logical Name: qa-test-generate
  • Command: /qa-test-generate
  • Role: qa
  • Output: $JAAN_OUTPUTS_DIR/qa/test-generate/{id}-{slug}/