oorty add
Add new test files to your project.
Usage
Terminal
npx oorty add [type] [options]Arguments
| Type | Description |
|---|---|
unit | Create a unit test for utilities and functions |
component | Create a component test for React components |
e2e | Create an E2E test for user flows |
Options
| Option | Default | Description |
|---|---|---|
-n, --name <name> | prompted | Name for the test file |
--cwd <path> | . | Set the working directory |
Examples
Add a unit test:
Terminal
npx oorty add unit --name utilsAdd a component test:
Terminal
npx oorty add component --name headerAdd an E2E test:
Terminal
npx oorty add e2e --name checkoutInteractive mode (prompts for type and name):
Terminal
npx oorty addGenerated Files
Each test type generates a different file structure:
Unit Test
tests/unit/utils.test.ts
// tests/unit/utils.test.tsimport { 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.tsximport { 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.tsimport { 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.