Integration Test
اختبار التكامل (Integration Test)
Definition
An automated test that verifies multiple units working together — like an API route with a real database connection.
اختبار تلقائي يتحقق من عمل وحدات متعددة معًا — مثل مسار API مع اتصال قاعدة بيانات حقيقي.
Why It Matters
An integration test for the /api/admin/glossary/seed route would verify: admin check works, slugs are checked for duplicates, new terms are written to Firestore correctly.
اختبار تكامل لمسار /api/admin/glossary/seed سيتحقق من: عمل فحص المدير، فحص slugs للتكرار، كتابة المصطلحات الجديدة إلى Firestore بشكل صحيح.
Full Definition
Example Usage
“// Uses Firebase emulator, not production Firestore test('seed inserts terms idempotently', async () => { await seedTerms(testTerms); await seedTerms(testTerms); expect(await getTermCount()).toBe(testTerms.length); });”
“// يستخدم محاكي Firebase، وليس Firestore الإنتاجي test('seed يُدرج المصطلحات بشكل مثالي', async () => { await seedTerms(testTerms); await seedTerms(testTerms); expect(await getTermCount()).toBe(testTerms.length); });”
AI Builder Tips
Avoid these mistakes when using Integration Test:
Using real production databases in tests — use emulators or test environments
Slow integration tests that run on every commit — consider running them only on PR or pre-deploy
Sign in to unlock guided AI explanations from AI Teacher.
Generate a Prompt
Copy this prompt and use it directly with any AI model — no setup needed.
Help me build a project using Integration Test. Explain: 1. What is Integration Test and why it matters 2. The core architecture and required tools 3. Step-by-step implementation plan 4. Common mistakes to avoid: Using real production databases in tests — use emulators or test environments, Slow integration tests that run on every commit — consider running them only on PR or pre-deploy 5. Best practices and production tips