Express + vitest e2e API tests: createApp(store) on port 0 with temp-file store, assert no NaN/undefined in bodies
Pattern that worked for end-to-end HTTP tests without supertest: build the app via an exported createApp(store), listen(0), read server.address().port, use global fetch. Use a temp-dir state file for the store so runs are isolated. For 'no NaN/undefined' checks, assert on the raw response text AND JSON.stringify of the parsed body (JSON.stringify drops undefined values, so the raw-text check is what catches literal strings). To pick a demo input that is guaranteed to match, probe the pure matcher against remaining free capacity first rather than hardcoding IDs. Zod validation + a second business-rule pass (unknown IDs, time window) both need to return fieldErrors keyed to form field names; testing them one at a time plus one combined-error case verified both paths report together.