fix(test): exclude Invalid Date from fc.date arbitrary in validation property test
Some checks failed
Veza CI / Rust (Stream Server) (push) Successful in 3m31s
Security Scan / Secret Scanning (gitleaks) (push) Successful in 1m8s
Veza CI / Backend (Go) (push) Successful in 5m14s
Veza CI / Frontend (Web) (push) Successful in 23m16s
Veza CI / Notify on failure (push) Has been skipped
E2E Playwright / e2e (full) (push) Has been cancelled

CI run 461 (frontend ci.yml) hit a true property-test flake:

  FAIL src/schemas/__tests__/validation.property.test.ts > property:
    isoDateSchema > accepts valid ISO 8601 datetime strings
  RangeError: Invalid time value
    at MapArbitrary.mapper validation.property.test.ts:73:12
        (d) => d.toISOString()

`fc.date({ min, max })` from fast-check can occasionally generate the
`new Date(NaN)` sentinel ("Invalid Date") even with min/max bounds. The
.map((d) => d.toISOString()) step then throws RangeError, failing the
property and the whole vitest run.

Fast-check 3.13+ exposes `noInvalidDate: true` as a generator option
that skips the NaN-Date sentinel; we're on 4.7, so the option is
available. Adding it makes the arbitrary deterministic-ish and
removes the flake.

Verified locally — 39/39 property tests pass repeatedly.

SKIP_TESTS=1 — single-file test fix already verified by hand.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
senke 2026-04-27 14:24:42 +02:00
parent 72ff070876
commit 27b57db3ea

View file

@ -68,10 +68,24 @@ function safeChatContent(min: number, max: number) {
/** Arbitrary that generates valid UUIDs */
const validUuid = fc.uuid();
/** Arbitrary that generates valid ISO 8601 datetime strings */
const validIsoDate = fc.date({ min: new Date('2000-01-01'), max: new Date('2099-12-31') }).map(
(d) => d.toISOString(),
);
/**
* Arbitrary that generates valid ISO 8601 datetime strings.
*
* `noInvalidDate: true` excludes the `new Date(NaN)` "Invalid Date"
* sentinel that fast-check's `fc.date()` would otherwise produce
* occasionally. Without it, a sporadic CI run hits
* RangeError: Invalid time value
* inside `.toISOString()` and fails the whole property suite a
* non-deterministic flake that has nothing to do with the property
* being asserted.
*/
const validIsoDate = fc
.date({
min: new Date('2000-01-01'),
max: new Date('2099-12-31'),
noInvalidDate: true,
})
.map((d) => d.toISOString());
/** Arbitrary that generates valid email-shaped strings */
const validEmail = fc