一键导入
test-coverage
Generate comprehensive tests for code - unit tests, edge cases, error conditions. Targets 70%+ coverage using Vitest.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Generate comprehensive tests for code - unit tests, edge cases, error conditions. Targets 70%+ coverage using Vitest.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Run Codex CLI, Claude Code, OpenCode, or Pi Coding Agent via background process for programmatic control.
Interact with GitHub using the gh CLI. Use gh issue, gh pr, gh run, and gh api for issues, PRs, CI runs, and advanced queries.
Track and summarize per-model usage costs for AI models. Useful for monitoring spending across Claude, GPT, and other providers.
Search and analyze your own session logs (older/parent conversations) using jq.
| name | test-coverage |
| description | Generate comprehensive tests for code - unit tests, edge cases, error conditions. Targets 70%+ coverage using Vitest. |
| metadata | {"emoji":"🧪","category":"development","tags":["testing","vitest","coverage","quality"]} |
Generate tests following existing codebase patterns with Vitest.
Generate tests for current file:
/test-coverage
Generate tests for specific function:
/test-coverage parseSshTarget
Check coverage report:
/test-coverage --report
Before generating tests:
Follow EndiorBot conventions:
import { describe, it, expect, beforeEach } from 'vitest';
import { functionToTest } from './module.js';
describe('functionToTest', () => {
beforeEach(() => {
// Reset state if needed
});
it('handles normal input correctly', () => {
expect(functionToTest('valid')).toBe(expected);
});
it('handles edge cases', () => {
expect(functionToTest('')).toBeNull();
expect(functionToTest(null)).toBeNull();
});
it('throws on invalid input', () => {
expect(() => functionToTest(invalid)).toThrow();
});
});
Happy Path Tests:
Edge Case Tests:
Error Condition Tests:
Security Tests (when applicable):
| Metric | Target | Priority |
|---|---|---|
| Lines | 70% | Required |
| Branches | 70% | Required |
| Functions | 70% | Required |
| Statements | 70% | Required |
Run all tests:
pnpm test
Run tests with coverage:
pnpm test:coverage
Run specific test file:
pnpm test src/path/to/file.test.ts
Watch mode:
pnpm test --watch
| Pattern | Use Case |
|---|---|
*.test.ts | Unit tests (colocated) |
*.e2e.test.ts | End-to-end tests |
*.integration.test.ts | Integration tests |
import { vi } from 'vitest';
const mockFn = vi.fn().mockReturnValue('mocked');
const mockAsync = vi.fn().mockResolvedValue('async result');
vi.mock('./dependency', () => ({
someFunction: vi.fn().mockReturnValue('mocked'),
}));
const spy = vi.spyOn(object, 'method');
expect(spy).toHaveBeenCalledWith(expected);
For EndiorBot SDLC compliance:
Test coverage is one of 6 signals in the Vibecoding Index:
src/test/ - use existing utilities when availableasync/await with it('...', async () => { ... })vi.stubEnv() in beforeEach, vi.unstubAllEnvs() in afterEach../sdlc/gates/ and ../sdlc/vibecoding/