Test APIs with integration tests, contract tests, and E2E validation. Covers Jest, Vitest, and Supertest for Node.js/TypeScript APIs. Includes test data management, fixtures, factories, environment configuration, CI/CD integration, mocking external services, and contract testing with OpenAPI validation. Use this skill when building test suites for REST APIs, validating API contracts, or setting up API testing infrastructure.
View on GitHubsrstomp/pokayokay
pokayokay
January 23, 2026
Select agents to install to:
npx add-skill https://github.com/srstomp/pokayokay/blob/main/plugins/pokayokay/skills/api-testing/SKILL.md -a claude-code --skill api-testingInstallation paths:
.claude/skills/api-testing/# API Integration Testing
Build robust test suites for your APIs.
## Testing Pyramid for APIs
```
▲
▲▲▲ E2E Tests
▲▲▲▲▲ (Full stack, real DB, slow)
▲▲▲▲▲▲▲
▲▲▲▲▲▲▲▲▲ Contract Tests
▲▲▲▲▲▲▲▲▲▲▲ (API shape validation)
▲▲▲▲▲▲▲▲▲▲▲▲▲
▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ Integration Tests
▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ (API + DB, services)
▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲
▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ Unit Tests
▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲ (Handlers, validators, utils)
```
| Level | What It Tests | Speed | Isolation |
|-------|---------------|-------|-----------|
| **Unit** | Individual functions, validators | Fast | High |
| **Integration** | API + database, services together | Medium | Medium |
| **Contract** | API shape matches spec | Fast | High |
| **E2E** | Full request flow, real environment | Slow | Low |
## Test Types Overview
### Integration Tests
Test your API endpoints with real (or test) database.
```typescript
describe('POST /users', () => {
it('creates a user with valid input', async () => {
const response = await request(app)
.post('/users')
.send({ email: 'test@example.com', name: 'Test User' })
.expect(201);
expect(response.body).toMatchObject({
id: expect.any(String),
email: 'test@example.com',
name: 'Test User',
});
});
});
```
### Contract Tests
Validate API responses match your OpenAPI spec.
```typescript
it('matches OpenAPI schema', async () => {
const response = await request(app).get('/users/1');
expect(response.body).toMatchSchema('User');
});
```
### E2E Tests
Test complete flows across multiple endpoints.
```typescript
describe('User registration flow', () => {
it('registers, verifies email, and logs in', async () => {
// 1. Register
const registerRes = await request(app)
.post('/auth/register')
.send({ email: 'new@example.com',