api-contract-testing

Validate API contracts between services using Pact, OpenAPI, and JSON Schema.

1|Updated Jun 15, 2026
One-click install
npx skills add https://github.com/abdullah72005/skills --skill api-contract-testing-abdullah72005
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-contract-testing
Source: https://github.com/abdullah72005/skills/tree/main/api-contract/.agents/skills/api-contract-testing
Command: npx skills add https://github.com/abdullah72005/skills --skill api-contract-testing-abdullah72005

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Microservices and API integrations break silently when providers change request or response formats without consumers knowing. This Skill helps you write contract tests that verify consumer-provider compatibility, catch breaking changes in CI, and validate schemas without running full end-to-end integration tests. ## Core Features & Use Cases - Consumer-Driven Contract Testing: Write Pact consumer and provider verification tests in TypeScript/Jest, including provider state handlers and error scenarios. - Schema Validation: Validate request and response payloads against OpenAPI specifications and JSON Schemas in TypeScript, Python, and Java (REST Assured). - CI/CD Integration: Publish pacts to a Pact Broker and gate deployments with can-i-deploy checks in GitHub Actions. - Use Case: Your OrderService depends on UserService. Write a Pact consumer test defining the expected user response, publish it to the broker, and have the provider verify it in CI so a breaking field rename fails the build before deployment. ## Quick Start Ask the AI to write a Pact consumer contract test for your service's GET endpoint, including matchers and a provider verification setup.

Frequently Asked Questions about api-contract-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Pact consumer contract test in TypeScript?

Use PactV3 from @pact-foundation/pact to define the consumer, provider, and expected interactions with matchers like like() and eachLike(). Execute the test against the mock server, then verify the generated pact file on the provider side with the Verifier class.

What is the difference between contract testing and integration testing?

Contract tests validate request and response formats between a consumer and provider independently, without running both services together. Integration tests run the full system, which is slower and harder to isolate failures in CI.

How do I validate API responses against an OpenAPI schema?

Load the OpenAPI spec with js-yaml and use express-openapi-validator middleware with validateRequests and validateResponses enabled. Requests or responses that violate the spec return validation errors automatically.

Can I use Pact Broker to gate deployments in CI?

Yes. Publish pacts with pact-broker publish after consumer tests, then run pact-broker can-i-deploy with the provider version and target environment. The pipeline fails if the provider has not verified all consumer contracts.

When should I not use contract testing?

Avoid contract tests for business logic, UI behavior, or implementation details, since they only verify interface compatibility. Also avoid hard-coding specific values; use matchers so contracts stay flexible across provider changes.