Gotchas
Tests run sequentially
Section titled “Tests run sequentially”All test files share one backend and one database, and each resets it in
beforeAll. In parallel they would wipe each other’s data. The template
already sets this in vitest.config.ts; with your own config add it yourself:
export default defineConfig({ test: { fileParallelism: false, },})allowedHosts: localhost only by default
Section titled “allowedHosts: localhost only by default”In test mode the client sends requests only to localhost, 127.0.0.1,
[::1] and the hosts you list. Anything else throws EberlyUnsafeHostError
in new World(), before the first request. Add a staging host if you need
one; never production.
export const eberly = { url: 'https://api.staging.example.com', allowedHosts: ['*.staging.example.com'], // …} satisfies EberlyConfigvitest doesn’t check types
Section titled “vitest doesn’t check types”A test with a type error still runs. Run pnpm typecheck (tsc --noEmit) in
CI, before pnpm test.
The spec changed → regenerate
Section titled “The spec changed → regenerate”pnpm run client:generate after every change of the swagger, then
pnpm typecheck.
Commit eberly/generated.ts and eberly/api/
Section titled “Commit eberly/generated.ts and eberly/api/”Then a contract change shows up in the diff of a pull request.
A status from a variable needs as const
Section titled “A status from a variable needs as const”Otherwise it is just number:
for (const s of [401, 403] as const) res.assert(s)Privacy-friendly analytics, no cookies.