oorty generate
ProGenerate all test files from your test plan using AI.
Usage
Terminal
npx oorty generateRequires Test Plan
Run
oorty plan first to generate a test plan. The generate command reads from .oorty/plans/test-plan.json by default.Oorty API key required
Options
| Option | Default | Description |
|---|---|---|
| --plan, -p | .oorty/plans/test-plan.json | Path to the JSON test plan file |
| --filter | all | Only generate this type (unit, component, integration, e2e, or all) |
| --file | - | Only generate tests for matching source/test file paths |
| --dry-run | false | Show what would be generated without writing files |
| --overwrite | false | Overwrite existing test files |
| --force | false | Overwrite existing files without confirmation |
| --yes, -y | false | Skip prompts and use default confirmations |
| --skip-testids | false | Skip adding data-testid attributes to source files |
| --parallel | 3 | Number of concurrent AI generations |
| --cwd | . | Working directory |
What It Does
The generate command performs these steps:
- Reads your test plan - Parses the markdown file for test specifications
- Analyzes source files - Reads the actual code to understand implementation details
- Generates test code - Creates framework-aware tests with real assertions
- Creates directories - Automatically creates tests/unit, tests/component, tests/integration, tests/e2e as needed
- Writes test files - Saves all generated tests to the appropriate locations
Example Output
Terminal
npx oorty generateReading test plan...Found 44 test specificationsGenerating tests...Created: tests/unit/formatCurrency.test.tsCreated: tests/unit/validateEmail.test.tsCreated: tests/unit/useCart.test.tsCreated: tests/unit/useAuth.test.tsCreated: tests/component/ProductCard.test.tsxCreated: tests/component/Header.test.tsxCreated: tests/component/CartSidebar.test.tsxCreated: tests/integration/api-checkout.test.tsCreated: tests/integration/api-auth.test.tsCreated: tests/e2e/checkout.spec.tsCreated: tests/e2e/authentication.spec.ts... and 35 moreGeneration 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'34describe('formatCurrency', () => {5 it('formats USD correctly', () => {6 expect(formatCurrency(1234.56)).toBe('$1,234.56')7 })89 it('handles zero values', () => {10 expect(formatCurrency(0)).toBe('$0.00')11 })1213 it('handles negative values', () => {14 expect(formatCurrency(-99.99)).toBe('-$99.99')15 })1617 it('handles large numbers', () => {18 expect(formatCurrency(1000000)).toBe('$1,000,000.00')19 })2021 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 firstnpx oorty generate --priority 1# Generate only unit testsnpx oorty generate --type unit# Generate only priority 1 component testsnpx oorty generate --priority 1 --type component# Preview what would be generatednpx oorty generate --dry-runExisting Files
By default, generate skips files that already exist. Use
--overwrite to regenerate existing test files.Workflow
The recommended workflow is:
- Run
oorty planto analyze your codebase - Review and edit the test plan if needed
- Run
oorty generate --priority 1to create critical tests first - Run
npm testto verify tests pass - Run
oorty coverageto see Vitest V8 coverage and a per-file summary - Continue with lower priority tests
- Commit and push to run CI
Related Commands
- oorty plan - Generate a test plan first
- oorty add - Add individual test files manually
- oorty doctor - Verify your setup is correct
- oorty coverage - Vitest coverage and file-level summary
Next: oorty coverage
Measure what your tests exercise with Vitest and V8.