mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
The suite was not timezone-pinned. CI runs UTC, so a whole class of day-bucketing defect was invisible to the gate while a contributor outside UTC saw a red suite on unmodified main. Verified: a UTC+14 host fails five tests on an otherwise green tree. Pin TZ=UTC in both vitest configs; tests that need a different HOST zone now set and restore it explicitly. The resting-pulse fixtures passed offset-less ISO literals, which parse as host-local, so they could not distinguish the Berlin day-key the implementation uses from a UTC one — swapping the day-key's zone left the file green. Build each instant explicitly in Berlin and add cases whose local day and UTC day genuinely differ; that swap now fails two of them. Delete the 'DST boundary (spring-forward)' compliance case. It passed no timezone, so the slot builder took the legacy UTC path where the date carries no transition, and it asserted totalExpected === 7 — which holds in every zone and therefore could never see the double-emit its own comment described. Threading a real zone does not rescue it: the assertion stays true in Berlin, UTC, UTC+14 and UTC-11 alike. The property it claimed is already pinned properly in the scheduling suite, which walks buildCadenceTimeline with an explicit zone across both the 23 h spring-forward and the 25 h fall-back day.
59 lines
2.2 KiB
TypeScript
59 lines
2.2 KiB
TypeScript
import { defineConfig } from "vitest/config";
|
|
import { dirname, resolve } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
globals: true,
|
|
environment: "node",
|
|
// Pin the host timezone. CI runs UTC; without this a contributor in any
|
|
// other zone sees a different suite than the gate does — verified: a
|
|
// UTC+14 host fails five tests on an otherwise green tree. Pinning makes
|
|
// local and CI agree, and makes "which zone does this test mean?" an
|
|
// explicit choice the fixture has to state rather than a property of the
|
|
// machine it runs on. Tests that need a different HOST zone set
|
|
// `process.env.TZ` themselves and restore it afterwards (see
|
|
// `next-due-day-label.test.ts`).
|
|
env: { TZ: "UTC" },
|
|
// Primes the i18n locale cache so provider mounts resolve every
|
|
// locale synchronously (production gets the active bundle as an RSC
|
|
// prop instead — see src/lib/i18n/load-locale.ts).
|
|
setupFiles: ["./vitest.setup.ts"],
|
|
// Default `pnpm test` keeps unit tests only — integration suite uses
|
|
// testcontainers and runs separately via `pnpm test:integration`.
|
|
exclude: [
|
|
"**/node_modules/**",
|
|
"**/dist/**",
|
|
"**/.next/**",
|
|
"tests/integration/**",
|
|
// Playwright E2E suite — driven separately via `pnpm e2e`.
|
|
"e2e/**",
|
|
// Live agent worktrees create copies of `src/` under
|
|
// `.claude/worktrees/`; vitest would otherwise pick those copies up
|
|
// and run their tests twice — possibly against stale snapshots.
|
|
".claude/worktrees/**",
|
|
],
|
|
coverage: {
|
|
provider: "v8",
|
|
// `include` enumerates the full source tree so the report shows
|
|
// per-file coverage for files never imported by a test (vitest 4
|
|
// dropped the `coverage.all` flag and uses `include` for this).
|
|
include: ["src/**/*.ts", "src/**/*.tsx"],
|
|
exclude: [
|
|
"src/generated/**",
|
|
"src/**/__tests__/**",
|
|
"src/**/*.test.ts",
|
|
"src/**/*.test.tsx",
|
|
],
|
|
},
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
"@": resolve(__dirname, "src"),
|
|
},
|
|
},
|
|
});
|