# Contract Testing Patterns

Pact consumer-driven contracts, provider verification, schema evolution

- Repository: https://github.com/vibeeval/vibecosystem (541 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-08-08
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add vibeeval/vibecosystem --skill contract-testing-patterns -g -a claude-code -y`
Codex: `npx skills add vibeeval/vibecosystem --skill contract-testing-patterns -g -a codex -y`
Cursor: `npx skills add vibeeval/vibecosystem --skill contract-testing-patterns -g -a cursor -y`
Gemini CLI: `npx skills add vibeeval/vibecosystem --skill contract-testing-patterns -g -a gemini-cli -y`

## Description

Pact consumer-driven contracts, provider verification, schema evolution

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Contract Testing Patterns

## Consumer-Driven Contract Testing with Pact

### Consumer Test (JavaScript)

```javascript
const { PactV3, MatchersV3 } = require('@pact-foundation/pact');
const { like, eachLike, string, integer } = MatchersV3;

const provider = new PactV3({
  consumer: 'OrderService',
  provider: 'UserService',
  logLevel: 'warn',
});

describe('User API Contract', () => {
  it('returns user by ID', async () => {
    await provider
      .given('user with ID 1 exists')
      .uponReceiving('a request for user 1')
      .withRequest({
        method: 'GET',
        path: '/api/users/1',
        headers: { Accept: 'application/json' },
      })
      .willRespondWith({
        status: 200,
        headers: { 'Content-Type': 'application/json' },
        body: {
          id: integer(1),
          name: string('Jane Doe'),
          email: string('jane@example.com'),
          roles: eachLike('admin'),
        },
      })
      .executeTest(async (mockServer) => {
        const client = new UserClient(mockServer.url);
        const user = await client.getUser(1);
        expect(user.id).toBe(1);
        expect(user.name).toBeDefined();
      });
  });
});
```

### Provider Verification

```javascript
const { Verifier } = require('@pact-foundation/pact');

The rest: https://github.com/vibeeval/vibecosystem/blob/HEAD/skills/contract-testing-patterns/SKILL.md
