# API Tests This directory contains reference contract tests and opt-in integration smoke tests for the eMoney control-plane API surface. The default repo validation pass does not start an external REST or GraphQL control-plane service, so the integration suites are intentionally opt-in. ## Test Structure ``` test/emoney/api/ ├── integration/ # Optional smoke tests against an external API service │ ├── rest-api.test.ts │ └── graphql.test.ts └── contract/ # Contract validation tests ├── openapi-validation.test.ts └── event-schema-validation.test.ts ``` Reference API specs used by the contract tests live under `test/api/packages/`. ## Running Tests ```bash # Run all tests pnpm test # Run only integration tests pnpm run test:integration # Run only contract tests pnpm run test:contract # Watch mode pnpm run test:watch ``` ## Test Types ### Integration Tests Test actual API endpoints against running services: - REST API operations - GraphQL queries and mutations - End-to-end flows Enable them explicitly: ```bash export RUN_EMONEY_API_INTEGRATION=1 export RUN_EMONEY_GRAPHQL_INTEGRATION=1 ``` ### Contract Tests Validate that implementations conform to specifications: - OpenAPI schema validation - AsyncAPI event schema validation - Request/response format validation ## Mock Servers Mock server tooling is not checked into this monorepo checkout. If you have an external mock or implementation, point the integration tests at it with environment variables. ```bash export API_URL=http://localhost:3000 export GRAPHQL_URL=http://localhost:4000/graphql export ACCESS_TOKEN=your-test-token ```