Command Palette

Search for a command to run...

oorty generate

Pro

Generate all test files from your test plan using AI.

Usage

Terminal
npx oorty generate

Options

OptionDefaultDescription
--plan, -p.oorty/plans/test-plan.jsonPath to the JSON test plan file
--filterallOnly generate this type (unit, component, integration, e2e, or all)
--file-Only generate tests for matching source/test file paths
--dry-runfalseShow what would be generated without writing files
--overwritefalseOverwrite existing test files
--forcefalseOverwrite existing files without confirmation
--yes, -yfalseSkip prompts and use default confirmations
--skip-testidsfalseSkip adding data-testid attributes to source files
--parallel3Number of concurrent AI generations
--cwd.Working directory

What It Does

The generate command performs these steps:

  1. Reads your test plan - Parses the markdown file for test specifications
  2. Analyzes source files - Reads the actual code to understand implementation details
  3. Generates test code - Creates framework-aware tests with real assertions
  4. Creates directories - Automatically creates tests/unit, tests/component, tests/integration, tests/e2e as needed
  5. Writes test files - Saves all generated tests to the appropriate locations

Example Output

Terminal
npx oorty generate
Reading test plan...
Found 44 test specifications
Generating tests...
Created: tests/unit/formatCurrency.test.ts
Created: tests/unit/validateEmail.test.ts
Created: tests/unit/useCart.test.ts
Created: tests/unit/useAuth.test.ts
Created: tests/component/ProductCard.test.tsx
Created: tests/component/Header.test.tsx
Created: tests/component/CartSidebar.test.tsx
Created: tests/integration/api-checkout.test.ts
Created: tests/integration/api-auth.test.ts
Created: tests/e2e/checkout.spec.ts
Created: tests/e2e/authentication.spec.ts
... and 35 more
Generation complete!
44 test files created
0 skipped (already exist)
Run 'npm test' to execute your tests.

Generated Test Example

Here's an example of a generated unit test:

tests/unit/utils/formatCurrency.test.ts
1import { describe, it, expect } from 'vitest'
2import { formatCurrency } from '@/utils/formatCurrency'
3
4describe('formatCurrency', () => {
5 it('formats USD correctly', () => {
6 expect(formatCurrency(1234.56)).toBe('$1,234.56')
7 })
8
9 it('handles zero values', () => {
10 expect(formatCurrency(0)).toBe('$0.00')
11 })
12
13 it('handles negative values', () => {
14 expect(formatCurrency(-99.99)).toBe('-$99.99')
15 })
16
17 it('handles large numbers', () => {
18 expect(formatCurrency(1000000)).toBe('$1,000,000.00')
19 })
20
21 it('rounds to two decimal places', () => {
22 expect(formatCurrency(10.999)).toBe('$11.00')
23 })
24})

Incremental Generation

Generate only specific priorities or types to work incrementally:

Terminal
# Generate only critical (priority 1) tests first
npx oorty generate --priority 1
# Generate only unit tests
npx oorty generate --type unit
# Generate only priority 1 component tests
npx oorty generate --priority 1 --type component
# Preview what would be generated
npx oorty generate --dry-run

Workflow

The recommended workflow is:

  1. Run oorty plan to analyze your codebase
  2. Review and edit the test plan if needed
  3. Run oorty generate --priority 1 to create critical tests first
  4. Run npm test to verify tests pass
  5. Run oorty coverage to see Vitest V8 coverage and a per-file summary
  6. Continue with lower priority tests
  7. Commit and push to run CI

Related Commands

Next: oorty coverage

Measure what your tests exercise with Vitest and V8.

coverage command