/** * Timeouts for Vitest tests that start a child process * (docs/work/reference/testing.md 2절: such a test declares its own timeout). * tests/setup.ts fails a test on the default timeout that starts one. * It is also the one way to give any test, describe or hook more than the * default, a long in-process run included, so every such number at a call is * a desktop measurement. tests/unit/test-timeout-declarations.test.ts refuses * a number written by hand (1112/03-08). */ /** `testTimeout` in vitest.config.ts, sized for tests that run in process. */ export const DEFAULT_TEST_TIMEOUT_MS = 10_000; /** * A child process slowed down far more than in-process code on a loaded * desktop: a documentation test that runs its checker as a child took 0.4 to * 1.2 s, and 10.6 s once inside an FE-GATE-020 drill (2026-11-12), so it * failed on the 10 s default. */ const LOADED_HOST_SLOWDOWN = 15; const STEP_MS = 30_000; /** * The timeout for a test, or for a describe, whose longest measured run took * `longestMeasuredMs`: fifteen times that, rounded up to a 30 s step. Measure * on desktop with the JSON reporter, with test:coverage and test:unit, and pass * the longest test of the describe. */ export function childProcessTimeout(longestMeasuredMs: number): number { return Math.max(1, Math.ceil((longestMeasuredMs * LOADED_HOST_SLOWDOWN) / STEP_MS)) * STEP_MS; }