Skillpedia
الاختبار75k · #2787

contract-testing

ما الذي تفعله

تشرح هذه المهارة كيفية كتابة اختبارات تصف ما تتوقعه الواجهة الأمامية من الخلفية، ثم تتحقق من أن الخلفية تلبي هذه التوقعات. وهي موجهة إلى الفرق التي تُنشر فيها الواجهة الأمامية والخلفية بشكل منفصل.

متى تستخدمها

  • ✓عندما تكسر التغييرات في الواجهة والخلفية بعضهما بشكل متكرر.
  • ✓عندما تكون اختبارات النهاية إلى النهاية بطيئة وهشة لأن الخدمتين يجب أن تعملا معًا.
  • ✓عندما تريد معرفة ما إذا كان يمكن نشر خدمتين بشكل مستقل.

رابط المهارة

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/contract-testing/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/contract-testing/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“أعدّ اختبارات عقود بين تطبيق الواجهة الأمامية وAPI الخاص به، حتى تُكتشف تغييرات الخلفية التي تكسر الواجهة في CI.”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

يضيف الوكيل اختبارات Pact من جهة المستهلك لعميل API، وينشر العقود المتوقعة إلى وسيط broker، ويضيف التحقق من المزوّد إلى خط أنابيب الخلفية.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Implement consumer-driven contract testing for API boundaries

Integration tests that require both services running at the same time are slow, brittle, and hard to maintain. Consumer-driven contract testing decouples the consumer and provider test suites — each team can run their tests independently, yet the broker guarantees that the published contract is always verified against the live provider. This catches API mismatches days earlier than end-to-end tests, with far less infrastructure overhead.

Quick Reference

  • The consumer writes tests that describe what it expects from the API (the "contract")
  • The contract is published to a Pact Broker and verified against the real provider
  • Provider changes that break the contract fail CI before they are deployed
  • This replaces fragile end-to-end tests that require both services to be running simultaneously

Check

Check whether the frontend has consumer-driven contract tests that define and verify the API contract with the backend.

Fix

Add Pact consumer tests for the frontend API client, publish the contracts to a broker, and add provider verification to the backend CI pipeline.

Explain

Explain how consumer-driven contract testing works, what the Pact workflow looks like end-to-end, and how it compares to mocking and end-to-end testing.

Code Review

Review the Pact consumer tests. Flag interactions that are too permissive (any-type matchers on fields the consumer actually uses), missing status code assertions, and interactions for endpoints the consumer no longer calls.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/testing/contract-testing

الأسئلة الشائعة

ما هو اختبار العقد؟

اختبار يسجل ما تتوقعه الواجهة من API، ثم يتحقق من أن API الفعلي يلبي هذه التوقعات.

ما الأداة التي تستخدمها المهارة؟

Pact، مع Pact Broker لمشاركة العقود.

كيف يختلف هذا عن اختبارات النهاية إلى النهاية؟

تقول المهارة إن اختبارات العقود لا تحتاج تشغيل الخدمتين معًا في الوقت نفسه، وتكشف عدم التطابق أبكر.

التفاصيل

الوصف الأصلي من المؤلف

Use when setting up integration testing for a frontend-backend API boundary, evaluating whether two services are safe to deploy independently, or replacing slow end-to-end tests with contract tests.

repo: thedaviddias/Front-End-Checklist

الشعبية

نجوم GitHub
75k
الترتيب
#2787
الترخيص
MIT
آخر تحديث
31‏/10‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة