with one click
test-file
Generate a test file for a component, hook, or utility
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
Generate a test file for a component, hook, or utility
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
Generate a new React component with Mantine styling
Update documentation after implementing features or making changes
Run a quick architecture review via architect-reviewer agent
Generate mobile-specific React components with platform detection and safe areas
Run a quick security audit on recent changes or specific files
Generate comprehensive tests via test-generator agent
| name | test-file |
| description | Generate a test file for a component, hook, or utility |
Generates test file scaffolding matching project conventions.
Co-located with source file as {filename}.test.ts or {filename}.test.tsx.
Read the target file to understand:
Determine test type:
Generate test file with appropriate mocks
import { render, screen, fireEvent } from '@testing-library/react';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { ComponentName } from './ComponentName';
// Mock contexts
vi.mock('@/contexts', () => ({
useObjects: () => ({
store: mockStore,
dataVersion: 1,
refreshData: vi.fn(),
}),
useNavigation: () => ({
navigate: vi.fn(),
}),
}));
// Mock Tauri
vi.mock('@tauri-apps/api/core', () => ({
invoke: vi.fn(),
}));
describe('ComponentName', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('renders correctly', () => {
render(<ComponentName />);
expect(screen.getByText('expected text')).toBeInTheDocument();
});
it('handles user interaction', () => {
render(<ComponentName />);
fireEvent.click(screen.getByRole('button'));
// Assert expected behavior
});
});
import { renderHook, act } from '@testing-library/react';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { useHookName } from './useHookName';
vi.mock('@/contexts', () => ({
useObjects: () => ({
store: mockStore,
dataVersion: 1,
refreshData: vi.fn(),
}),
}));
describe('useHookName', () => {
beforeEach(() => {
vi.clearAllMocks();
});
it('returns expected initial state', () => {
const { result } = renderHook(() => useHookName());
expect(result.current.value).toBe(expected);
});
it('updates state correctly', () => {
const { result } = renderHook(() => useHookName());
act(() => {
result.current.setValue('new value');
});
expect(result.current.value).toBe('new value');
});
});
import { describe, it, expect } from 'vitest';
import { utilityFunction } from './utility';
describe('utilityFunction', () => {
it('handles normal input', () => {
expect(utilityFunction('input')).toBe('expected');
});
it('handles edge cases', () => {
expect(utilityFunction('')).toBe('');
expect(utilityFunction(null)).toBeNull();
});
it('throws on invalid input', () => {
expect(() => utilityFunction(undefined)).toThrow();
});
});
import { describe, it, expect, beforeEach } from 'vitest';
import { LoroDocStore } from '@/lib/loro/LoroDocStore';
import { ObjectStore } from '@/lib/loro/ObjectStore';
import { registerBuiltInTypes } from '@/lib/types/built-in-types';
describe('Feature Integration', () => {
let store: ObjectStore;
beforeEach(() => {
const docStore = new LoroDocStore();
store = new ObjectStore(docStore.doc);
registerBuiltInTypes(store);
});
it('creates and retrieves objects', () => {
const obj = store.create({
typeId: 'built-in:task',
properties: { title: 'Test Task' },
});
expect(store.get(obj.id)).toBeDefined();
expect(store.get(obj.id)?.properties.title).toBe('Test Task');
});
});
Mock at boundaries only:
// Tauri API
vi.mock('@tauri-apps/api/core', () => ({
invoke: vi.fn(),
}));
// File system
vi.mock('@tauri-apps/plugin-fs', () => ({
readTextFile: vi.fn(),
writeTextFile: vi.fn(),
}));
Use real implementations for:
.test.ts or .test.tsx suffixpnpm test (watch) or pnpm test:run (CI)