Testing
E2E Tests (Playwright)
End-to-end tests live in e2e/ and use Playwright with Chromium.
Configuration
typescript
// playwright.config.ts
{
testDir: './e2e',
fullyParallel: true,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
baseURL: 'http://localhost:6173',
webServer: {
command: 'npm run dev',
url: 'http://localhost:6173',
reuseExistingServer: !process.env.CI,
},
}Running Tests
bash
# Run all E2E tests
npm test
# Interactive UI mode
npm run test:uiPlaywright automatically starts the dev server if it isn't running.
Test Files
Tests cover the chat widget, page navigation, and adversarial scenarios:
e2e/
├── chat-adversarial.spec.ts # Security and edge case tests
├── chat.spec.ts # Core chat functionality
├── ...Chat Test Bypass
E2E tests bypass rate limiting via the X-Bypass-Rate-Limit header with the RATE_LIMIT_BYPASS_TOKEN value.
Worker Tests (Vitest)
Chat worker tests use Vitest with @cloudflare/vitest-pool-workers to run tests in a Workers-like environment.
Configuration
typescript
// chat-worker/vitest.config.ts
defineWorkersConfig({
test: {
poolOptions: {
workers: {
wrangler: { configPath: './wrangler.toml' },
isolatedStorage: false,
miniflare: {
bindings: {
SLACK_BOT_TOKEN: 'xoxb-test-token',
SLACK_SIGNING_SECRET: 'test-signing-secret-for-ci',
// ... other test bindings
},
},
},
},
},
});Running Worker Tests
bash
cd chat-worker
npm testTest Files
chat-worker/test/
├── routes.test.ts # HTTP endpoint tests
├── chat-session.test.ts # Durable Object lifecycle tests
├── ai-engine.test.ts # AI engine unit tests
├── slack.test.ts # Slack API integration tests
├── env.d.ts # Test environment types
└── tsconfig.json # Test TypeScript configIsolated Storage
Isolated storage is disabled (isolatedStorage: false) because Durable Objects with WebSockets and alarms perform async storage writes that outlive individual test boundaries.