Test Specialist
Comprehensive JavaScript/TypeScript testing guidance with test writing, bug analysis, coverage analysis, and proactive issue detection.
Your test coverage is at 30%, bugs keep shipping to production, and nobody on the team enjoys writing tests. This playbook provides comprehensive JS/TS testing guidance — writing effective unit and integration tests, analyzing coverage gaps, and proactively detecting issues before they reach users.
Who it's for: JavaScript developers wanting to improve test quality beyond basic snapshot tests, frontend teams building comprehensive test suites for React components and hooks, Node.js engineers writing integration tests for API endpoints and middleware, tech leads establishing testing standards and coverage requirements for their teams, QA engineers transitioning from manual testing to automated test development
Example
"Add comprehensive tests to our Express API with 30% coverage" → Test specialist pipeline: coverage gap analysis identifying untested critical paths, unit test generation for business logic and utility functions, integration test creation for API endpoints with database mocking, edge case identification for error handling and boundary conditions, and CI configuration for coverage reporting with minimum thresholds
CLAUDE.md Template
New here? 3-minute setup guide → | Already set up? Copy the template below.
# Test Specialist
## Your Role
You are my testing specialist for JavaScript/TypeScript projects. Help me write comprehensive tests, analyze bugs, identify coverage gaps, and detect potential issues proactively.
## Core Capabilities
### 1. Test Writing
Write tests using Arrange-Act-Assert pattern:
- Unit tests for individual functions/components
- Integration tests for module interactions
- E2E tests for complete user flowsGet new playbooks like this one
One email a week with new Claude Code workflows. Free, like everything here.
No spam. Unsubscribe anytime.
What This Does
Complete testing guidance for JavaScript/TypeScript projects. Write unit, integration, and E2E tests. Analyze bugs systematically. Identify coverage gaps. Detect potential issues proactively.
Quick Start
Step 1: Navigate to Your Project
cd ~/your-js-project
Step 2: Download the Template
Click Download above, then:
mv ~/Downloads/CLAUDE.md ./
Step 3: Start Testing
claude
Then ask: "Help me write tests for the user authentication module"
Testing Approach
Arrange-Act-Assert Pattern
describe('UserService', () => {
it('should create a new user', async () => {
// Arrange
const userData = { email: 'test@example.com', name: 'Test' };
// Act
const user = await userService.create(userData);
// Assert
expect(user.email).toBe('test@example.com');
});
});
Testing Types
| Type | Purpose | Tools |
|---|---|---|
| Unit | Individual functions/components | Jest, Vitest |
| Integration | Module interactions | Jest, Supertest |
| E2E | Full user flows | Playwright, Cypress |
Example Prompts
Test Writing
- "Write unit tests for this function"
- "Create integration tests for the API endpoints"
- "Generate E2E tests for the checkout flow"
Bug Analysis
- "Help me debug this failing test"
- "Find the root cause of this bug"
- "This test is flaky - help me fix it"
Coverage
- "Find untested code in this project"
- "Which files need more test coverage?"
- "Prioritize what to test next"
Bug Analysis Process
- Reproduce: Confirm the issue exists
- Isolate: Find the minimal reproduction case
- Root Cause: Identify why it happens
- Fix: Implement the solution
- Validate: Add tests to prevent regression
Common Bug Patterns
| Pattern | Symptom | Solution |
|---|---|---|
| Race Condition | Intermittent failures | Add proper async handling |
| Null/Undefined | TypeError crashes | Add null checks |
| Off-by-One | Wrong counts/indices | Review loop boundaries |
| State Mutation | Unexpected side effects | Use immutable patterns |
Test Coverage Strategy
Priority Order:
- Critical business logic
- Edge cases and error handling
- Happy path flows
- Integration points
- UI components
Security Testing
Include tests for:
- SQL injection prevention
- XSS sanitization
- Authentication bypasses
- Authorization checks
Tips
- One behavior per test: Keep tests focused
- Test the interface: Not the implementation
- Independent tests: No order dependencies
- Clear naming: Test name should explain what and why