Command Palette

Search for a command to run...

oorty add

Add new test files to your project.

Usage

Terminal
npx oorty add [type] [options]

Arguments

TypeDescription
unitCreate a unit test for utilities and functions
componentCreate a component test for React components
e2eCreate an E2E test for user flows

Options

OptionDefaultDescription
-n, --name <name>promptedName for the test file
--cwd <path>.Set the working directory

Examples

Add a unit test:

Terminal
npx oorty add unit --name utils

Add a component test:

Terminal
npx oorty add component --name header

Add an E2E test:

Terminal
npx oorty add e2e --name checkout

Interactive mode (prompts for type and name):

Terminal
npx oorty add

Generated Files

Each test type generates a different file structure:

Unit Test

tests/unit/utils.test.ts
// tests/unit/utils.test.ts
import { describe, it, expect } from 'vitest'
describe('utils', () => {
it('should pass a basic test', () => {
expect(true).toBe(true)
})
it('should perform addition correctly', () => {
const add = (a: number, b: number) => a + b
expect(add(2, 3)).toBe(5)
})
})

Component Test

tests/component/header.test.tsx
// tests/component/header.test.tsx
import { describe, it, expect } from 'vitest'
import { render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
describe('Header', () => {
it('renders correctly', () => {
render(
)
expect(screen.getByRole('banner')).toBeInTheDocument()
})
it('handles navigation', async () => {
const user = userEvent.setup()
render(
)
await user.click(screen.getByRole('link', { name: /home/i }))
})
})

E2E Test

tests/e2e/checkout.spec.ts
// tests/e2e/checkout.spec.ts
import { test, expect } from '@playwright/test'
test.describe('checkout', () => {
test('completes checkout flow', async ({ page }) => {
await page.goto('/cart')
await page.click('text=Checkout')
await expect(page).toHaveURL('/checkout')
})
})

Next: oorty plan (Pro)

Generate an AI test plan from your codebase, then use oorty generate to scaffold tests from the plan.

plan command