一键导入
write-tests
Write tests following this project's testing conventions, file patterns, and placement rules
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Write tests following this project's testing conventions, file patterns, and placement rules
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Create a changeset entry describing changes to workspace packages
Scaffold a new UI component with the correct folder structure, styles, tests, and docblocks
Scaffold a new class with the correct file structure, naming, tests, and docblocks
Scaffold a new runtime type guard with the correct naming and docblocks
Scaffold a new utility function with the correct naming, tests, and docblocks
Create a git commit following this project's commit message conventions
| name | write-tests |
| description | Write tests following this project's testing conventions, file patterns, and placement rules |
| user-invocable | false |
When writing tests in this project, follow these conventions exactly.
| Type | File pattern | Runner | Purpose |
|---|---|---|---|
| Unit | *.unit.ts / *.unit.tsx | Vitest | Isolated logic, single module |
| Integration | *.integration.ts / *.integration.tsx | Vitest | Cross-module interaction |
| Performance | *.bench.ts / *.bench.tsx | Vitest Bench | Execution speed and regression guard |
| E2E | *.e2e.ts / *.e2e.tsx | Vitest | Full application user flows |
Tests live in a specs/ folder colocated with the code they test (inside each subdirectory of a module).
src/classes/
├── MyClass.ts
└── specs/
└── MyClass.unit.ts
src/components/
└── MyComponent/
├── component.tsx
└── specs/
└── MyComponent.unit.tsx
src/services/
├── ThingService.ts
└── specs/
└── ThingService.unit.ts
parseSelector.ts → specs/parseSelector.unit.tsserializeNode.ts → specs/serializeNode.unit.tsselectors.unit.ts or serialization.unit.ts when the production code is split across multiple utility files.Use the testing/ directory within modules for shared mocks, factories, and test utilities.
src/testing/
├── mocks/
└── factories/
Performance benchmarks use Vitest's bench API. They live in specs/ alongside other tests.
src/classes/
├── MyClass.ts
└── specs/
├── MyClass.unit.ts
└── MyClass.bench.ts
Benchmarks track the execution performance of specific operations. They run across many iterations automatically and report ops/sec, helping detect performance regressions as the library evolves.
import {bench, describe} from 'vitest';
import {MyClass} from '../MyClass';
const input = generateRealisticInput(); // Setup outside bench callback
describe('MyClass', () => {
bench('processes a typical document tree', () => {
const instance = new MyClass();
instance.doWork(input);
});
bench('processes a large document tree', () => {
const instance = new MyClass();
instance.doWork(largeInput);
});
});
.bench.ts file.bench() call so setup cost is not measured.pnpm test:performancespecs/ folder with the correct suffixsrc/testing/ where appropriatepnpm run check to verify tests pass