Loading...
Loading...
Generate runnable Vitest and Playwright test files from BDD test cases and scaffold code. Use when generating test implementations.
npx skill4agent add parhumm/jaan-to qa-test-generateProduce runnable Vitest unit tests and Playwright E2E specs from BDD test cases and scaffold code.
$JAAN_CONTEXT_DIR/tech.md#current-stack#frameworks#constraints#patterns$JAAN_CONTEXT_DIR/config.md$JAAN_TEMPLATES_DIR/jaan-to:qa-test-generate.template.md$JAAN_LEARN_DIR/jaan-to:qa-test-generate.learn.md$JAAN_OUTPUTS_DIR/research/71-qa-bdd-gherkin-test-code-generation.md${CLAUDE_PLUGIN_ROOT}/docs/extending/language-protocol.md/jaan-to:qa-test-cases/jaan-to:backend-scaffold/jaan-to:frontend-scaffold/jaan-to:backend-api-contract${CLAUDE_PLUGIN_ROOT}/docs/extending/pre-execution-protocol.mdqa-test-generate$JAAN_OUTPUTS_DIR/research/71-qa-bdd-gherkin-test-code-generation.md$JAAN_CONTEXT_DIR/tech.md${CLAUDE_PLUGIN_ROOT}/docs/extending/language-protocol.mdlanguage_qa-test-generateLanguage exception: Generated code output (variable names, code blocks, test files, config files) is NOT affected by this setting and remains in the project's programming language.
Feature:@tagsScenario:INPUT SUMMARY
-------------------------------------------------------------
Sources Found: {list of found artifacts}
Sources Missing: {list with impact assessment}
BDD Scenarios: {total count}
@smoke: {count}
@unit: {count}
@integration: {count}
@e2e: {count}
@boundary: {count}
@edge-case: {count}
Testable Code Units:
Services: {count from scaffold}
Routes/Handlers: {count from scaffold}
Components/Hooks: {count if frontend}
Schemas: {count}
API Endpoints: {count from contract, or "N/A"}$JAAN_CONTEXT_DIR/tech.md#frameworksReference: Seesection "Detailed Tag Routing Map" for the full tag-to-tier routing table with target descriptions.${CLAUDE_PLUGIN_ROOT}/docs/extending/qa-test-generate-reference.md
TEST GENERATION PLAN
-------------------------------------------------------------
Config Files:
- vitest.config.ts (workspace with unit + integration)
- playwright.config.ts (with playwright-bdd)
- test/setup/unit.ts (MSW server setup)
- test/setup/integration.ts (DB + MSW setup)
- test/mocks/server.ts (MSW server instance)
- test/mocks/handlers.ts (auto-generated from API contract)
Test Data:
- test/factories/{entity}.factory.ts ({count} factories)
- test/fixtures/db-seed.ts (DB seeding scenarios)
- test/utils/test-utils.ts (shared test helpers)
Unit Tests ({count} files):
{list of service.test.ts and hook.test.ts files}
Integration Tests ({count} files):
{list of integration.test.ts files}
E2E Tests ({count} files):
{list of Playwright .spec.ts files per user flow}
Coverage Targets:
- Unit: 80% line, 70% branch
- Integration: 60% line
- E2E: 100% of acceptance criteria scenarios
- BDD: All Given/When/Then steps mapped to assertionsFINAL CONFIRMATION
-------------------------------------------------------------
Source Artifacts:
- qa-test-cases: {path}
- scaffold: {path}
- api-contract: {path or "N/A"}
Test Framework Stack:
- Unit/Integration: {Vitest/Jest}
- E2E: {Playwright/Cypress}
- BDD Binding: {jest-cucumber adapted for Vitest / playwright-bdd}
- Mocking: {MSW / nock}
- Factories: {Fishery + @anatine/zod-mock / faker.js}
Output Folder: $JAAN_OUTPUTS_DIR/qa/test-generate/{id}-{slug}/
Total Files: {count}
Files to Generate:
Config: {count} files (vitest.config.ts, playwright.config.ts, setup files)
Factories: {count} files (test data factories + db-seed)
Unit Tests: {count} files ({total_scenarios} scenarios)
Integration: {count} files ({total_scenarios} scenarios)
E2E Tests: {count} files ({total_scenarios} scenarios)
Utilities: {count} files (test-utils, msw-handlers)Reference: Seesection "Config Generation Specifications" for Vitest workspace, Playwright, and setup file configurations.${CLAUDE_PLUGIN_ROOT}/docs/extending/qa-test-generate-reference.md
Reference: Seesection "Test Data Layer Patterns" for factory, MSW handler, DB seed, and test utility generation patterns.${CLAUDE_PLUGIN_ROOT}/docs/extending/qa-test-generate-reference.md
Reference: Seesection "BDD Binding Code Templates" for the feature-scoped step definition code template.${CLAUDE_PLUGIN_ROOT}/docs/extending/qa-test-generate-reference.md
vi.mock()expect()renderHookrenderReference: Seesection "Integration Test Patterns" for API and service integration test generation patterns.${CLAUDE_PLUGIN_ROOT}/docs/extending/qa-test-generate-reference.md
createBddReference: Seesection "Playwright BDD Step Templates" for the playwright-bdd step definition code template.${CLAUDE_PLUGIN_ROOT}/docs/extending/qa-test-generate-reference.md
Reference: Seesection "E2E Page Object Patterns" for page object generation and fixture composition patterns.${CLAUDE_PLUGIN_ROOT}/docs/extending/qa-test-generate-reference.md
Reference: Seesection "Quality Check Checklist" for the full validation checklist (completeness, test data, configuration, code quality).${CLAUDE_PLUGIN_ROOT}/docs/extending/qa-test-generate-reference.md
source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/id-generator.sh"
SUBDOMAIN_DIR="$JAAN_OUTPUTS_DIR/qa/test-generate"
mkdir -p "$SUBDOMAIN_DIR"
NEXT_ID=$(generate_next_id "$SUBDOMAIN_DIR")Runnable test suite for {feature_name} generated from {scenario_count} BDD scenarios
and {scaffold_type} scaffold code. Includes {unit_count} Vitest unit tests,
{integration_count} integration tests, and {e2e_count} Playwright E2E specs.
Test infrastructure: {factory_count} data factories, MSW mock handlers,
Vitest workspace config, and Playwright BDD config. Coverage targets:
80% line (unit), 60% line (integration), 100% scenario (E2E).OUTPUT PREVIEW
-------------------------------------------------------------
ID: {NEXT_ID}
Folder: $JAAN_OUTPUTS_DIR/qa/test-generate/{NEXT_ID}-{slug}/
Files:
{NEXT_ID}-{slug}.md (Test strategy + coverage map)
config/
vitest.config.ts (Workspace config)
playwright.config.ts (BDD + projects config)
setup/unit.ts (MSW lifecycle)
setup/integration.ts (DB + MSW setup)
mocks/server.ts (MSW server)
mocks/handlers.ts (Auto-generated handlers)
test-utils.ts (Shared helpers + matchers)
unit/
{service-name}.test.ts ({n} scenarios)
...
integration/
{resource-name}.integration.test.ts ({n} scenarios)
...
e2e/
{flow-name}.spec.ts ({n} scenarios)
steps/{feature}.steps.ts (Step definitions)
steps/fixtures.ts (Page object fixtures)
pages/{page}.page.ts (Page objects)
fixtures/
factories/{entity}.factory.ts ({n} factories)
db-seed.ts (Seed scenarios)
[Show first unit test file as preview snippet]
[Show first E2E step definition as preview snippet]OUTPUT_FOLDER="$JAAN_OUTPUTS_DIR/qa/test-generate/${NEXT_ID}-${slug}"
mkdir -p "$OUTPUT_FOLDER"
mkdir -p "$OUTPUT_FOLDER/config/setup"
mkdir -p "$OUTPUT_FOLDER/config/mocks"
mkdir -p "$OUTPUT_FOLDER/unit"
mkdir -p "$OUTPUT_FOLDER/integration"
mkdir -p "$OUTPUT_FOLDER/e2e/steps"
mkdir -p "$OUTPUT_FOLDER/e2e/pages"
mkdir -p "$OUTPUT_FOLDER/fixtures/factories"$OUTPUT_FOLDER/${NEXT_ID}-${slug}.md$JAAN_TEMPLATES_DIR/jaan-to:qa-test-generate.template.md$OUTPUT_FOLDER/config/$OUTPUT_FOLDER/unit/$OUTPUT_FOLDER/integration/$OUTPUT_FOLDER/e2e/$OUTPUT_FOLDER/fixtures/source "${CLAUDE_PLUGIN_ROOT}/scripts/lib/index-updater.sh"
add_to_index \
"$SUBDOMAIN_DIR/README.md" \
"$NEXT_ID" \
"${NEXT_ID}-${slug}" \
"{Feature Name} Test Suite" \
"{Executive Summary}"TEST SUITE GENERATED
-------------------------------------------------------------
ID: {NEXT_ID}
Folder: $JAAN_OUTPUTS_DIR/qa/test-generate/{NEXT_ID}-{slug}/
Index: Updated $JAAN_OUTPUTS_DIR/qa/test-generate/README.md
Total Files: {count}
Config: {count}
Unit Tests: {count} ({scenario_count} scenarios)
Integration: {count} ({scenario_count} scenarios)
E2E Tests: {count} ({scenario_count} scenarios)
Fixtures: {count} ({factory_count} factories)
Coverage Targets:
Unit: 80% line, 70% branch
Integration: 60% line
E2E: 100% of acceptance criteriaTest suite generated successfully!Next Steps:
- Copy test files to your project's
directorytest/- Run
to add test dependencies (vitest, playwright, fishery, msw, etc.)npm install- Run
to execute unit testsnpx vitest run --workspace=unit- Run
to execute E2E testsnpx playwright test- Run
to review test quality (when available)/jaan-to:qa-test-review- See the main document for full CI integration guide
/jaan-to:learn-add qa-test-generate "{feedback}"Reference: Seesection "Key Generation Rules" for BDD-to-assertion mapping table, tag-to-tier routing, test data factory and MSW handler patterns, and anti-patterns to avoid.${CLAUDE_PLUGIN_ROOT}/docs/extending/qa-test-generate-reference.md
tech.md$JAAN_OUTPUTS_DIRReference: Seesection "Definition of Done Checklist" for the complete checklist.${CLAUDE_PLUGIN_ROOT}/docs/extending/qa-test-generate-reference.md