Skip to content

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.sh before every run

Read the E2E Testing Guide

Test Coverage Areas

AreaPHPUnitJestPlaywright
Knowledge CRUDOrchestrator, entityknowledge.test.tstests/knowledge/
CategoriesCategoryServicecategories.test.tstests/categories/
DigestsDigestOrchestrator, formatterdigest.test.tstests/digests/
SubscriptionsSubscriptionServicesubscriptions.test.tstests/api/subscriptions/
Slack App HomedynamicHome.test.tstests/slack-ui/
Notion syncNotionSyncServicetests/notion/
Full workflowstests/workflows/

E2E Test Environment

E2E tests require a controlled environment to prevent data pollution:

  • Test database: backend/var/data_test.db (NOT data.db)
  • Mock APIs: NOTION_MOCK=true, OPENAI_MOCK=true
  • Lock file: /.test-env-lock must exist for Playwright to start
  • Always run /scripts/ensure-test-env.sh before E2E tests

WARNING

NEVER start Symfony in dev mode for E2E tests. Without mocks, Notion sync re-imports deleted test data.

CI Workflows

WorkflowScope
.github/workflows/php-checks.ymlPHP CS Fixer, PHPStan, PHPUnit
.github/workflows/ts-checks.ymlPrettier, TypeScript, Jest