api-contract-testing

Featured

Verifies API contracts between services using consumer-driven contracts, schema validation, and tools like Pact. Use when testing microservices communication, preventing breaking changes, or validating OpenAPI specifications.

Testing & QA 221 stars 31 forks Updated today MIT

Install

View on GitHub

Quality Score: 91/100

Stars 20%
78
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# API Contract Testing Verify that APIs honor their contracts between consumers and providers without requiring full integration tests. ## Key Concepts | Term | Definition | |------|------------| | Consumer | Service that calls an API | | Provider | Service that exposes an API | | Contract | Agreed request/response format | | Pact | Consumer-driven contract testing tool | | Schema | Structure definition (OpenAPI, JSON Schema) | | Broker | Central repository for contracts | ## Pact Consumer Test (TypeScript) ```typescript import { PactV3, MatchersV3 } from '@pact-foundation/pact'; const provider = new PactV3({ consumer: 'OrderService', provider: 'UserService' }); describe('User API Contract', () => { it('returns user by ID', async () => { await provider .given('user 123 exists') .uponReceiving('a request for user 123') .withRequest({ method: 'GET', path: '/users/123' }) .willRespondWith({ status: 200, body: MatchersV3.like({ id: '123', name: MatchersV3.string('John'), email: MatchersV3.email('john@example.com') }) }) .executeTest(async (mockServer) => { const response = await fetch(`${mockServer.url}/users/123`); expect(response.status).toBe(200); }); }); it('returns 404 for non-existent user', async () => { await provider .given('user does not exist') .uponReceiving('a request for non-existent user') .withRequest({ method:...

Details

Author
secondsky
Repository
secondsky/claude-skills
Created
10 months ago
Last Updated
today
Language
TypeScript
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category