# End-to-end tests on one local stack that a killed run never leaves behind

apps/e2e runs web and iOS end-to-end tests with e2e on the built Worker and a locked temporary PostgreSQL; test-local-postgres and the RLS matrix sweep what a killed run left.

- **Web and iOS end-to-end tests.** `pnpm test:e2e` builds the Worker and runs the web suite in `apps/e2e` with [e2e](https://e2e.com/docs) 0.23.1: sign up, verify, sign in; the seeded Member's session; create and delete a todo; `/docs`; the anonymous dashboard redirect; and the todo flow driven by agent goals, which skips without a model and replays from `apps/e2e/recordings/` once recorded. `pnpm test:e2e:mobile` signs the seeded Member in on the Expo development build and finds a seeded todo. Locators come from the apps' own English catalogs. ([End-to-end tests](/docs/development/e2e), [f5b4ef72](https://github.com/CarlosZiegler/template-cloudflare/commit/f5b4ef72), [993c4f49](https://github.com/CarlosZiegler/template-cloudflare/commit/993c4f49))
- **One stack per machine, and nothing left behind.** The suites' app command starts the built Worker in local workerd on a temporary PostgreSQL under a lock: a second run fails at once naming the owner pid, a dead owner's lock is taken over and its cluster and workerd stopped, a killed runner's stack stops itself, and the mobile wrapper shuts down only a simulator it booted. `node scripts/e2e-cleanup-proof.mjs` proves a normal run, `kill -9` mid-run and two runs at once. ([End-to-end tests](/docs/development/e2e#one-stack-and-nothing-left-behind), [f5b4ef72](https://github.com/CarlosZiegler/template-cloudflare/commit/f5b4ef72))
- **Killed test runs no longer leave servers or containers.** `scripts/test-local-postgres.mjs --serve` records its dev server group, and the next run stops it with the orphaned cluster; a SIGKILLed run used to leave wrangler/workerd serving. `test:rls-matrix` starts its containers with `--rm`, cleans up on SIGTERM and SIGHUP, and first removes, with their volumes, the containers of runs that are gone. ([Testing](/docs/development/testing), [6616cf79](https://github.com/CarlosZiegler/template-cloudflare/commit/6616cf79), [3d1f95cf](https://github.com/CarlosZiegler/template-cloudflare/commit/3d1f95cf))
- **CI.** A new `e2e` workflow runs the web suite on same-repository pull requests and pushes to `main` with the runner's own PostgreSQL binaries and uploads `apps/e2e/.e2e/`; it holds no deploy or database secret. ([End-to-end tests](/docs/development/e2e#ci), [475c4251](https://github.com/CarlosZiegler/template-cloudflare/commit/475c4251))
