Files
clean-architecture-frontend…/tests/setup.ts
T
DongHyeonka ba72b86595
frontend-quality-gates / merge / static checks (pull_request) Successful in 2m7s
frontend-quality-gates / merge / tests (pull_request) Successful in 20m56s
frontend-quality-gates / merge / browser tests (pull_request) Successful in 6m56s
frontend-quality-gates / FE-GATE-014 / config-compatibility (pull_request) Skipped
frontend-quality-gates / FE-GATE-028 / manual-accessibility-review (pull_request) Skipped
frontend-quality-gates / FE-GATE-026 / lab-performance (pull_request) Skipped
frontend-quality-gates / FE-GATE-015 / immutable-release-candidate (pull_request) Skipped
frontend-quality-gates / external-vulnerability-provider (pull_request) Skipped
frontend-quality-gates / external-provenance-provider (pull_request) Skipped
frontend-quality-gates / promote-verified-immutable-candidate (pull_request) Skipped
frontend-quality-gates / deploy-promoted-release (pull_request) Skipped
frontend-quality-gates / FE-GATE-019 / hosting-header (pull_request) Skipped
frontend-quality-gates / FE-GATE-021 / runbook-boot-config (pull_request) Skipped
frontend-quality-gates / FE-GATE-022 / runbook-chunk-mismatch (pull_request) Skipped
frontend-quality-gates / FE-GATE-023 / runbook-api-degradation (pull_request) Skipped
frontend-quality-gates / FE-GATE-024 / runbook-telemetry (pull_request) Skipped
frontend-quality-gates / FE-GATE-025 / runbook-release-rollback (pull_request) Skipped
frontend-quality-gates / FE-GATE-018 / field-web-vitals (pull_request) Skipped
frontend-quality-gates / main / checker self-tests (pull_request) Skipped
frontend-quality-gates / FE-GATE-017 / diagram-review (pull_request) Skipped
chore(merge): FE-GATE-013 판정·시험 timeout PR들이 들어간 main을 받는다
main(5250ff95)의 PR #17·#18·#20·#21·#22를 받는다. 충돌 정리:
- tests/setup.ts: main의 자식 프로세스 timeout 감시를 그대로 두고, Testing
  Library는 DOM이 있는 파일에만 불러오는 이 브랜치의 방식을 남긴다.
- tests/system/ci-runner/ci-artifact-contract.test.ts: main이 같은 결함
  (.claude 추적 파일 ENOENT)을 저장소 배치 등록부의 provider-fixture-skip
  집합으로 이미 고쳤다. main 쪽을 받고 이 브랜치의 f90ffb6c 고침은 버린다.
  CHANGELOG의 그 행도 지운다.
- 작업 매뉴얼·스킬(gates.md 3절, operate·improve·new-feature, evidence,
  desktop-gates·fe-testing 스킬): 기본은 시스템 컨테이너 경로, main의 D8
  판정(사전 점검의 userns 제한 하나뿐이고 뒤 명령 모두 rc=0이면 merge
  판정에서 뺀다)은 컨테이너를 띄울 수 없는 호스트에 쓴다.
- 그 호스트에서 D8 절차를 그대로 돌릴 수 있게 scripts/verify.sh에
  VERIFY_HOST_ENVIRONMENT=off(hostEnvironment 게이트를 이 호스트에서 바로
  돈다)를 더하고 원격 실행에도 넘긴다. 시험 하나를 더한다.
- decisions.md는 main 그대로(D8이 2.2절에 있어 이 브랜치의 O-21 행은 겹친다).

검증(노트북): python3 -m unittest discover -s scripts/tests 73개 통과,
scripts/verify.sh docs rc=0. desktop merge 단계는 이 커밋에서 다시 돈다.
2026-11-12 20:00:50 +09:00

79 lines
3.7 KiB
TypeScript

import { createRequire, syncBuiltinESMExports } from "node:module";
import { afterEach, beforeEach, vi } from "vitest";
import { DEFAULT_TEST_TIMEOUT_MS } from "./helpers/child-process-timeout.ts";
// Testing Library and its matchers need a DOM. Most test files run in Node
// (tests/unit has over 200, three of them with jsdom), and importing React DOM
// and Testing Library into every one of them was the largest part of the
// suite's setup time. They load only where the file's environment has a DOM.
async function loadDomTesting(): Promise<() => void> {
await import("@testing-library/jest-dom/vitest");
const { cleanup, configure } = await import("@testing-library/react");
// findBy*/waitFor settle on the DOM change itself; their deadline only reports
// a hang. Routes render through React.lazy, and React 19 holds every Suspense
// reveal on a real 300ms timer (FALLBACK_THROTTLE_MS). A route entered through
// a context table and then a lazy page spends 600ms of the 1s default before
// any rendering work, so on a loaded host the default turns into a speed
// requirement. Fake timers cannot shorten it: Testing Library advances only
// Jest's fake timers, and MSW and user-event run on the real clock. Half the
// 10s test timeout still reports a real hang with the DOM dump.
configure({ asyncUtilTimeout: 5_000 });
return cleanup;
}
const cleanup = typeof document === "undefined" ? undefined : await loadDomTesting();
afterEach(() => {
cleanup?.();
// A test that fails before its own vi.useRealTimers() must not leave fake
// timers to the next test in the file.
vi.useRealTimers();
});
/**
* A test that starts a child process declares its own timeout
* (docs/work/reference/testing.md 2절). On a loaded desktop a 0.7 s
* documentation test took 10.6 s and failed FE-GATE-020 on the default, which
* is sized for tests that run in process. A test still on the default fails
* here, at the call, also when a helper or a script it imports starts the
* process. Hooks are not checked: they have no test of their own.
*/
type ChildProcessCall = (this: unknown, ...args: unknown[]) => unknown;
const guard = globalThis as typeof globalThis & {
__childProcessTimeoutGuard?: { timeout: number | undefined };
};
if (!guard.__childProcessTimeoutGuard) {
const state: { timeout: number | undefined } = { timeout: undefined };
guard.__childProcessTimeoutGuard = state;
const childProcess = createRequire(import.meta.url)("node:child_process") as Record<string, ChildProcessCall>;
for (const name of ["spawn", "spawnSync", "exec", "execSync", "execFile", "execFileSync", "fork"]) {
const original = childProcess[name]!;
const checked: ChildProcessCall = function (this: unknown, ...args: unknown[]) {
if (state.timeout === DEFAULT_TEST_TIMEOUT_MS) {
throw new Error(
`${name}(${String(args[0])}) ran in a test on the default ${DEFAULT_TEST_TIMEOUT_MS} ms timeout. ` +
"Give the test, or its describe, childProcessTimeout(<longest measured ms>) from tests/helpers/child-process-timeout.ts.",
);
}
return original.apply(this, args);
};
// util.promisify(execFile) and the like read properties of the function.
for (const key of Reflect.ownKeys(original)) {
if (key !== "length" && key !== "name" && key !== "prototype") {
Object.defineProperty(checked, key, Reflect.getOwnPropertyDescriptor(original, key)!);
}
}
childProcess[name] = checked;
}
syncBuiltinESMExports();
}
const childProcessGuard = guard.__childProcessTimeoutGuard;
beforeEach((context) => {
childProcessGuard.timeout = context.task.timeout;
});
afterEach(() => {
childProcessGuard.timeout = undefined;
});