# Testing Best Practices

> Guidelines for writing effective tests

- Skill: `willayam/testing-best-practices` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add willayam/testing-best-practices`
- Raw SKILL.md: https://api.skillmd.com/api/skills/willayam/testing-best-practices/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: Willayam (https://skillmd.com/u/willayam)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/willayam/testing-best-practices

---


# Testing Best Practices

## Unit Tests

- Test one thing per test
- Use descriptive test names
- Arrange-Act-Assert pattern
- Mock external dependencies

## Integration Tests

- Test component interactions
- Use realistic test data
- Clean up after tests

## Example Test Structure

```typescript
describe('UserService', () => {
  it('should create a user with valid data', async () => {
    // Arrange
    const userData = { name: 'Test', email: 'test@example.com' };
    
    // Act
    const user = await userService.create(userData);
    
    // Assert
    expect(user.name).toBe('Test');
  });
});
```

