ワンクリックで
test-helper
Generate comprehensive test cases following TDD principles
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Generate comprehensive test cases following TDD principles
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Comprehensive code review focusing on quality, security, and best practices
Generate comprehensive documentation for code, APIs, and projects
Generate clear, conventional commit messages and manage Git workflows
Internationalization and localization assistance for multi-language applications
Identify code smells and suggest refactoring improvements
| name | test-helper |
| description | Generate comprehensive test cases following TDD principles |
| allowed-tools | ["Read","Write","Bash","Grep"] |
| origin | bundled |
| version | 1.0.0 |
Generate high-quality test cases following Test-Driven Development (TDD) principles and best practices.
Always write tests BEFORE implementation:
Test individual functions/methods in isolation.
describe('retryOperation', () => {
it('should retry failed operations up to 3 times', async () => {
let attempts = 0;
const operation = () => {
attempts++;
if (attempts < 3) throw new Error('fail');
return 'success';
};
const result = await retryOperation(operation);
expect(result).toBe('success');
expect(attempts).toBe(3);
});
it('should throw error after max retries exceeded', async () => {
const operation = () => {
throw new Error('persistent failure');
};
await expect(retryOperation(operation)).rejects.toThrow('persistent failure');
});
it('should return immediately on first success', async () => {
let attempts = 0;
const operation = () => {
attempts++;
return 'success';
};
await retryOperation(operation);
expect(attempts).toBe(1);
});
});
Test interactions between components.
describe('UserService', () => {
let db: Database;
let userService: UserService;
beforeEach(async () => {
db = await createTestDatabase();
userService = new UserService(db);
});
afterEach(async () => {
await db.close();
});
it('should create user and store in database', async () => {
const userData = {
email: 'test@example.com',
name: 'Test User'
};
const user = await userService.createUser(userData);
expect(user.id).toBeDefined();
expect(user.email).toBe(userData.email);
const stored = await db.users.findById(user.id);
expect(stored).toEqual(user);
});
});
Test complete user workflows.
describe('User Registration Flow', () => {
it('should allow new user to register and login', async () => {
// Register
const response = await request(app)
.post('/api/register')
.send({
email: 'newuser@example.com',
password: 'SecurePass123!',
name: 'New User'
});
expect(response.status).toBe(201);
expect(response.body.success).toBe(true);
// Login
const loginResponse = await request(app)
.post('/api/login')
.send({
email: 'newuser@example.com',
password: 'SecurePass123!'
});
expect(loginResponse.status).toBe(200);
expect(loginResponse.body.token).toBeDefined();
});
});
it('should do something specific', () => {
// Arrange - Set up test data and conditions
const input = 'test data';
const expected = 'expected result';
// Act - Execute the code under test
const result = functionUnderTest(input);
// Assert - Verify the result
expect(result).toBe(expected);
});
Good Names:
should return user when valid ID providedshould throw error when email already existsshould retry 3 times before failingBad Names:
test1it worksuser test// Good: Mock external API
const mockFetch = jest.fn().mockResolvedValue({
json: () => Promise.resolve({ data: 'test' })
});
// Bad: Over-mocking internal logic
const mockAdd = jest.fn((a, b) => a + b); // Just test the real function!