@thalorlabs/api-test-suite
v1.0.0
Published
Standardised integration test suite for ThalorLabs microservices
Downloads
17
Readme
@thalorlabs/api-test-suite
Standardised integration tests for ThalorLabs microservices. One function call gives you the 90% of tests every MS needs.
Installation
npm install -D @thalorlabs/api-test-suiteUsage
import { runStandardApiTests } from '@thalorlabs/api-test-suite';
import { app } from '../src/index';
runStandardApiTests({
app,
route: '/api/v1/jokes',
method: 'GET',
validApiKey: 'test-api-key',
});What it tests
| Category | Tests | |----------|-------| | Routing | Route returns expected status, unknown routes return 404, response is JSON | | Authentication | Missing key → 401, wrong key → 401, empty key → 401 | | Health | GET /health returns 200 without auth, GET /alive returns 200 | | Error contract | Error responses include status field, no stack traces leaked |
Config
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| app | Express | required | The Express app instance |
| route | string | required | Route to test (e.g. '/api/v1/jokes') |
| method | string | 'GET' | HTTP method |
| validApiKey | string | required | Valid API key for auth tests |
| requiresAuth | boolean | true | Whether the route requires auth |
| expectedStatus | number | 200 | Expected success status code |
