Description
Is your feature request related to a problem?
Backend tests hit fixed payloads. The highest-value API bug is the input that slips past zod
validation and crashes a handler — an uncontrolled 500 instead of a controlled 4xx.
Example-based tests don't explore that input space.
Describe the solution you'd like
Add fast-check to backend/ and fuzz routes through supertest against the in-process Express
app, reusing the vi.hoisted Prisma-mock pattern from authController.test.ts. Core invariants:
- bad/random input -> a controlled
4xx, never a 5xx;
- a protected route ->
401 when the token is absent/malformed, whatever the body;
- the response body is always valid JSON and never leaks a stack trace;
- if a
zod schema accepts an input, the handler must not crash on that same input.
Also fuzz the zod schemas directly (src/validation/schemas/*): safeParse(anything) never
throws (only returns { success: false }), .transform() steps are idempotent, numeric bounds
hold at the edges (0, negatives, floats, MAX_SAFE_INTEGER + 1, "1e999").
Alternatives considered
zod-fast-check targets zod v3; we are on v4, so arbitraries are hand-written or derived from
fc.anything().
Acceptance Criteria
Description
Is your feature request related to a problem?
Backend tests hit fixed payloads. The highest-value API bug is the input that slips past
zodvalidation and crashes a handler — an uncontrolled
500instead of a controlled4xx.Example-based tests don't explore that input space.
Describe the solution you'd like
Add
fast-checktobackend/and fuzz routes throughsupertestagainst the in-process Expressapp, reusing the
vi.hoistedPrisma-mock pattern fromauthController.test.ts. Core invariants:4xx, never a5xx;401when the token is absent/malformed, whatever the body;zodschema accepts an input, the handler must not crash on that same input.Also fuzz the
zodschemas directly (src/validation/schemas/*):safeParse(anything)neverthrows (only returns
{ success: false }),.transform()steps are idempotent, numeric boundshold at the edges (0, negatives, floats,
MAX_SAFE_INTEGER + 1,"1e999").Alternatives considered
zod-fast-checktargets zod v3; we are on v4, so arbitraries are hand-written or derived fromfc.anything().Acceptance Criteria
fast-checkadded as a dev dependency inbackend/.zodschema fuzzed for the "never throws / bounds hold" properties.backend/'s test command and in CI.