When to activate
- Generating test suites from OpenAPI specifications
- Creating contract tests to validate API responses against schemas
- Building integration tests for endpoint workflows
- Setting up load tests for performance benchmarks
- Automating regression tests for API changes
When NOT to use
- For unit testing business logic (use language-specific test tools)
- For E2E frontend testing
- For database migration testing
Instructions
- Parse OpenAPI spec. Extract all paths, methods, request bodies, response schemas, and auth requirements.
- Generate contract tests. For each endpoint, validate response status codes, headers, and JSON schema conformance.
- Build integration tests. Chain related endpoints (create → read → update → delete) with data assertions.
- Create edge case tests. Missing fields, invalid types, boundary values, unauthorized access, rate limit triggers.
- Set up test fixtures. Seed data, auth tokens, and environment configs for test isolation.
- Generate load tests. k6 or Artillery scripts targeting critical endpoints with ramp-up scenarios.
- Output test report. Pass/fail summary, coverage %, uncovered endpoints, and performance metrics.
Example
// Contract test — GET /users/{id}
describe('GET /users/{id}', () => {
it('returns 200 with valid user schema', async () => {
const res = await request.get('/users/123', { headers: authHeader });
expect(res.status).toBe(200);
expect(res.body).toMatchSchema(userSchema);
expect(res.headers['content-type']).toContain('application/json');
});
it('returns 404 for non-existent user', async () => {
const res = await request.get('/users/000000', { headers: authHeader });
expect(res.status).toBe(404);
expect(res.body.error.code).toBe('USER_NOT_FOUND');
});
});
1---2name: api-test-generator3description: Generate comprehensive API test suites — contract tests, integration tests, and load tests from OpenAPI specs4---56## When to activate78- Generating test suites from OpenAPI specifications9- Creating contract tests to validate API responses against schemas10- Building integration tests for endpoint workflows11- Setting up load tests for performance benchmarks12- Automating regression tests for API changes1314## When NOT to use1516- For unit testing business logic (use language-specific test tools)17- For E2E frontend testing18- For database migration testing1920## Instructions21221. **Parse OpenAPI spec.** Extract all paths, methods, request bodies, response schemas, and auth requirements.232. **Generate contract tests.** For each endpoint, validate response status codes, headers, and JSON schema conformance.243. **Build integration tests.** Chain related endpoints (create → read → update → delete) with data assertions.254. **Create edge case tests.** Missing fields, invalid types, boundary values, unauthorized access, rate limit triggers.265. **Set up test fixtures.** Seed data, auth tokens, and environment configs for test isolation.276. **Generate load tests.** k6 or Artillery scripts targeting critical endpoints with ramp-up scenarios.287. **Output test report.** Pass/fail summary, coverage %, uncovered endpoints, and performance metrics.2930## Example3132```javascript33// Contract test — GET /users/{id}34describe('GET /users/{id}', () => {35 it('returns 200 with valid user schema', async () => {36 const res = await request.get('/users/123', { headers: authHeader });37 expect(res.status).toBe(200);38 expect(res.body).toMatchSchema(userSchema);39 expect(res.headers['content-type']).toContain('application/json');40 });4142 it('returns 404 for non-existent user', async () => {43 const res = await request.get('/users/000000', { headers: authHeader });44 expect(res.status).toBe(404);45 expect(res.body.error.code).toBe('USER_NOT_FOUND');46 });47});48```