Integration Tests
Exercise a live worker end to end across REST, GraphQL, and RPC, with one shared cookie jar.
Integration tests hit a running worker over real HTTP. base test provides the harness: it resolves where the worker lives, wires the environment into jest, and runs everything matching *.integration.test.ts.
One thing to know first
base test does not start your worker. It targets one that's already running:
- Locally: run
npx base develop -w appin another shell; the test host resolves fromsettings.server['@default']. - In CI / against an environment: point settings at a deployed worker, e.g.
server: { Integration: { host: 'https://app-test.example.workers.dev' } }, and runnpx base test -w app -e Integration.
Host resolution precedence: --test-host flag → TEST_HOST env var → settings.server[<environment>] → settings.server['@default']. (base test refuses to run against Production.)
Write a test
Everything starts at IntegrationTestEnvironment.get().client:
Every surface, one client
The client speaks all three dispatch surfaces, and they share one cookie jar — sign in over REST, then call GraphQL or RPC as that session:
Cookies are managed through accessors (getCookies(), setCookie(name, value), clearAllCookies()) and captured automatically from Set-Cookie responses. getWebSocket() and getOrmDatabase(entities) exist for socket and direct-database assertions.
Useful flags
Tests run in-band with a 60s default timeout (override with --test-timeout). The scaffold's npm run test:integration wraps the --all-workers form.