v1.0.0 cosmicstack-labs
API Testing
REST and GraphQL testing, Postman/Insomnia patterns, contract testing, schema validation, and monitoring
View source0 downloads
apitestingrestgraphqlcontract-testing
API Testing#
Test REST and GraphQL APIs systematically.
Test Categories#
| Category | What | Example |
|---|---|---|
| Functional | Does it work? | POST /users returns 201 |
| Validation | Input handling | Missing required field → 400 |
| Auth | Access control | No token → 401 |
| Edge Cases | Boundary conditions | Max page size, empty results |
| Contract | Schema conformance | Response matches OpenAPI spec |
| Performance | Within SLO | p95 < 500ms |
REST API Testing#
Structure#
describe('POST /users', () => {
it('creates a user with valid data', async () => {
const res = await request(app)
.post('/api/users')
.send({ name: 'Alice', email: 'alice@test.com' });
expect(res.status).toBe(201);
expect(res.body).toHaveProperty('id');
});
it('rejects duplicate email', async () => {
const res = await request(app)
.post('/api/users')
.send({ name: 'Alice', email: 'existing@test.com' });
expect(res.status).toBe(409);
});
});Contract Testing (Pact)#
- Provider publishes OpenAPI spec
- Consumer tests verify against published spec
- CI rejects PR if contract breaks
- Prevents API drift between services
GraphQL Testing#
- Test queries and mutations independently
- Validate against schema
- Test error paths (partial failures, null propagation)
API Monitoring#
- Synthetic checks every 5 minutes
- Assert status, response time, required fields
- Alert on SLA breaches
- Monitor from multiple regions
More in Testing & QA
View all →Testing & QAv1.0.0
Accessibility Testing
WCAG 2.1/2.2 audit, axe, Lighthouse, manual testing, screen reader testing, and remediation
accessibilitya11ytesting
Testing & QAv1.0.0
E2E Testing
Playwright and Cypress patterns, selectors, assertions, API mocking, visual testing, and CI/CD
e2etestingplaywright
Testing & QAv1.0.0
Performance Testing
Load, stress, spike testing with k6/Locust, bottleneck analysis, and performance test automation
performancetestingload-testing