Testing Strategy Overview
The Yappa Knowledge Hub uses a three-layer testing strategy: PHPUnit for backend domain logic, Jest for Slack bot units, and Playwright for end-to-end API and Slack UI flows.
The Testing Pyramid
1. PHPUnit Backend Testing
- Where:
backend/tests/Unit/ - Focus: Entities, mappers, DTOs, orchestrators, digest pipeline, Notion sync services
- Tools: PHPUnit 11, Symfony PHPUnit Bridge, SQLite test database
- Not covered here: HTTP controller tests (see Playwright E2E)
Read the Backend Testing Guide
2. Slack Bot Testing (Jest)
- Where:
slack/tests/unit/ - Focus: Handler routing, service clients, App Home view builders
- Tools: Jest with ES module support
Read the Slack Bot Testing Guide
3. Playwright E2E Testing
- Where:
e2e-tests/ - Focus: REST API, Slack bot HTTP endpoints, App Home/modals, digest workflows, Notion sync (mocked)
- Tools: Playwright Test, TypeScript
- Test guard: Requires
/scripts/ensure-test-env.shbefore every run
Test Coverage Areas
| Area | PHPUnit | Jest | Playwright |
|---|---|---|---|
| Knowledge CRUD | Orchestrator, entity | knowledge.test.ts | tests/knowledge/ |
| Categories | CategoryService | categories.test.ts | tests/categories/ |
| Digests | DigestOrchestrator, formatter | digest.test.ts | tests/digests/ |
| Subscriptions | SubscriptionService | subscriptions.test.ts | tests/api/subscriptions/ |
| Slack App Home | — | dynamicHome.test.ts | tests/slack-ui/ |
| Notion sync | NotionSyncService | — | tests/notion/ |
| Full workflows | — | — | tests/workflows/ |
E2E Test Environment
E2E tests require a controlled environment to prevent data pollution:
- Test database:
backend/var/data_test.db(NOTdata.db) - Mock APIs:
NOTION_MOCK=true,OPENAI_MOCK=true - Lock file:
/.test-env-lockmust exist for Playwright to start - Always run
/scripts/ensure-test-env.shbefore E2E tests
WARNING
NEVER start Symfony in dev mode for E2E tests. Without mocks, Notion sync re-imports deleted test data.
CI Workflows
| Workflow | Scope |
|---|---|
.github/workflows/php-checks.yml | PHP CS Fixer, PHPStan, PHPUnit |
.github/workflows/ts-checks.yml | Prettier, TypeScript, Jest |