一键导入
unit-test-writer
Writes unit tests for existing source code. Use this when the user asks to create, write, or generate tests for their code, functions, or modules.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Writes unit tests for existing source code. Use this when the user asks to create, write, or generate tests for their code, functions, or modules.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Generates a README.md file for a project. Use this when the user asks to create, write, or generate a README for their project or repository.
Reviews code for quality, bugs, and improvements. Use this when the user asks to review, audit, or check their code for issues, best practices, or potential bugs.
Analyzes CSV files and generates summary reports when users have data files to analyze. Use this skill when the user asks to analyze, summarize, or get insights from a CSV file.
Generates Word documents (.docx) when users need project reports, meeting minutes, or other formatted documents. Use this skill when the user asks to create, write, or generate a document in docx/Word format.
Generates typed API client code from OpenAPI/Swagger specs. Use this when the user asks to create an API client, SDK, or typed HTTP wrapper from an API specification file.
Writes clear, conventional commit messages by analyzing staged changes. Use this when the user asks to write, draft, or suggest a commit message for their changes.
| name | unit-test-writer |
| description | Writes unit tests for existing source code. Use this when the user asks to create, write, or generate tests for their code, functions, or modules. |
| version | 1.0.0 |
Generate comprehensive unit tests for existing source code.
This skill analyzes source code files and produces well-structured unit tests that cover key functionality, edge cases, and error conditions. It adapts to the project's existing test framework and conventions, producing tests that integrate seamlessly into the existing test suite.
Read and Analyze Source Code
Identify the Test Framework
package.json for test dependencies (jest, vitest, mocha, pytest, etc.)Catalog Testable Units
Design Test Cases
describe blocks (or equivalent)should return X when given YWrite the Test File
*.test.ts / *.test.js for JavaScript/TypeScripttest_*.py / *_test.py for Python*_test.go for GoInclude Mocks and Fixtures
Run the Tests
describe('add', () => {
it('should return the sum of two positive numbers', () => {
expect(add(2, 3)).toBe(5);
});
it('should handle negative numbers', () => {
expect(add(-1, 1)).toBe(0);
});
});
describe('fetchUser', () => {
it('should return user data for valid ID', async () => {
const user = await fetchUser(1);
expect(user.name).toBeDefined();
});
it('should throw for invalid ID', async () => {
await expect(fetchUser(-1)).rejects.toThrow();
});
});
describe('UserService', () => {
it('should call repository with correct ID', () => {
const mockRepo = { findById: vi.fn().mockResolvedValue({ id: 1 }) };
const service = new UserService(mockRepo);
await service.getUser(1);
expect(mockRepo.findById).toHaveBeenCalledWith(1);
});
});