← Back to list

contract-test-gates
by AmnadTaowsoam
⭐ 0🍴 0📅 Jan 24, 2026
SKILL.md
name: Contract Test Gates description: Gates สำหรับ enforce API contract testing ระหว่าง services ด้วย Pact หรือ OpenAPI validation
Contract Test Gates
Overview
Gates สำหรับ enforce API contract testing - ทำให้แน่ใจว่า producer และ consumer ใช้ contract เดียวกัน
Why This Matters
- Integration safety: ไม่ break consumers
- Early detection: รู้ก่อน deploy
- Documentation: Contract = living docs
- Confidence: Deploy independently
Contract Testing
Producer Side
// API must match contract
describe('User API Contract', () => {
it('GET /users/:id matches contract', async () => {
const response = await request(app).get('/users/123');
// Validate against OpenAPI spec
expect(response).toMatchOpenAPISchema('User');
expect(response.body).toHaveProperty('id');
expect(response.body).toHaveProperty('email');
});
});
Consumer Side
// Consumer expectations
const userPact = new Pact({
consumer: 'frontend',
provider: 'user-api'
});
it('can get user by ID', async () => {
await userPact
.given('user 123 exists')
.uponReceiving('a request for user 123')
.withRequest({
method: 'GET',
path: '/users/123'
})
.willRespondWith({
status: 200,
body: {
id: '123',
email: 'test@example.com'
}
});
// Test consumer code
const user = await userService.getUser('123');
expect(user.id).toBe('123');
});
CI Pipeline
# .github/workflows/contract-tests.yml
name: Contract Tests
on: [pull_request]
jobs:
contract:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run Contract Tests
run: npm run test:contract
- name: Publish Pacts
run: npm run pact:publish
- name: Verify Contracts
run: npm run pact:verify
Summary
Contract Test Gates: Enforce API contracts
Types:
- Producer tests (API matches spec)
- Consumer tests (expectations met)
- Contract verification (both sides agree)
Tools:
- Pact (consumer-driven)
- OpenAPI validation
- Postman/Bruno collections
Policy: Must pass before merge
Score
Total Score
60/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon