문제: Vitest는 skip·todo 테스트를 통과로 센다. `it.skip`이나
`it.todo`가 든 파일은 CI=true에서도 종료 코드 0으로 끝난다.
`context.skip()`도 같다. `.only`는 Vitest 기본값 때문에 CI에서만 막히고,
로컬에서는 같은 파일의 나머지 테스트를 조용히 건너뛴다.
check:test-evidence의 소스 검사가 quarantine 주석 없는 `.skip(`·`.only(`
글자를 잡지만, `it.todo`, `context.skip()`, `skipIf`는 보지 못한다.
고른 방법:
- vitest.config.ts에 allowOnly: false를 둬 `.only`를 어디서나 막는다.
- scripts/lib/no-skipped-tests-reporter.ts reporter가 실행 끝에
state가 skipped인 테스트를 찾으면 이름을 출력하고 exitCode를 1로 둔다.
-t, 태그 필터, file:line처럼 호출자가 일부러 좁힌 실행은 예외다.
게이트는 실행을 좁히지 않는다.
- reporter는 scripts/run-vitest.ts가 붙인다. CLI --reporter는 config의
reporters를 대체하므로 config에 두면 package script에서 빠진다.
run-vitest.ts는 package script와 scale tier가 모두 거치는 입구다.
호출자가 reporter를 하나도 주지 않으면 default를 함께 붙인다.
버린 대안:
- 리뷰 최소 개선안의 junit `skipped > 0` 검사: Vitest junit은 mode가
skip·todo인 테스트만 <skipped/>로 적고 `context.skip()`은 통과처럼
적는다. junit을 쓰지 않는 실행(scale tier, http-scenario-catalog,
로컬 단일 파일)은 아예 보지 못한다.
- tests/setup.ts의 afterAll 검사: 모든 테스트가 skip인 파일은 hook이
돌지 않아 잡지 못한다.
- eslint-plugin-vitest no-disabled-tests: 새 의존성이 생기고
`context.skip()`을 못 잡는다.
위험·한계:
- run-vitest.ts를 거치지 않는 직접 `vitest` 실행에는 reporter가 붙지
않는다. allowOnly는 config라서 그때도 적용된다.
- 호출자가 reporter를 주지 않으면 default reporter를 고정해서 붙인다.
Vitest가 AI 에이전트 환경에서 고르는 agent reporter 대신 default가
나온다.
- 본문 없는 `describe.todo`처럼 테스트가 없는 묶음은 세지 않는다.
- check:test-evidence는 quarantine 주석이 있는 `.skip(`을 허용하지만
이 reporter는 Vitest에서 그것도 실패시킨다. 지금 quarantine은
Playwright spec에만 있어 충돌하는 테스트는 없다. 전략 문서 16.5절에
"quarantine은 Vitest 테스트를 통과시키지 않는다"고 적었다. Vitest에도
quarantine이 필요해지면 허용 목록을 따로 둬야 한다.
- 지금 저장소의 Vitest 테스트에는 skip·todo·only가 없다.
검증:
- RED(P-B 재현, run-vitest.ts로 skip+todo, only, context.skip() 파일을
CI 없음/CI=true로): 수정 전 6경우 중 5경우 exit 0("1 passed | 1
skipped | 1 todo"). only+CI=true만 exit 1.
- 새 tests/unit/no-skipped-tests-reporter.test.ts는 수정 전 "Cannot find
module ../../scripts/lib/no-skipped-tests-reporter.ts"로 실패.
- GREEN: 같은 6경우 모두 exit 1. skip·todo·context.skip()은 "N test(s)
did not run" 목록, only는 "Unexpected .only modifier". junit reporter를
준 실행도 exit 1. -t로 좁힌 실행과 file:line 실행은 exit 0. 새 테스트
11 passed.
- 빠른 계층 전체(unit·component·integration·contract·runtime-schema·
platform·architecture·features·release·scripts·recipes, pnpm 설치를
하는 fixture-node-modules.test.ts 제외, maxWorkers 4): 3,228 passed,
1 failed. 실패는 provider-guardian-transaction의 fs.watch ENOSPC(호스트
inotify 한도)이고 reporter 없이 vitest를 직접 돌려도 같다. skip 목록
출력은 없었다.
- tsc -p tsconfig.node.json, tsconfig.test.json, eslint(바꾼 4파일),
check-ci-contract, generate-ci-workflow --check,
verify-documentation-readiness(PASS_SCOPED) 통과.
Refs: docs/reviews/2026-11-01-maturity-review/10-tests-fast-layers.md 10-04
58 lines
2.4 KiB
TypeScript
58 lines
2.4 KiB
TypeScript
import { configDefaults, defineConfig } from "vitest/config";
|
|
|
|
import { isNpmScopeEnvironmentName } from "./scripts/lib/package-script-graph.ts";
|
|
|
|
// Tests must not inherit a caller's production React/runtime selection.
|
|
// Package scripts also launch Vitest through scripts/run-vitest.ts, which owns
|
|
// NODE_ENV before the Vitest process starts. Keeping the config deterministic
|
|
// protects direct `vitest` invocations as well.
|
|
process.env.NODE_ENV = "test";
|
|
// 1101/15-05. `npx vitest` and npm-launched IDE runners set npm_config_prefix,
|
|
// _userconfig and _globalconfig. The CI gate preflight refuses those in a real
|
|
// runner (scripts/contracts/ci-gates.ts), so tests that run it, in process or
|
|
// as a child, failed for the caller's environment. Tests start without them.
|
|
for (const name of Object.keys(process.env)) {
|
|
if (isNpmScopeEnvironmentName(name)) delete process.env[name];
|
|
}
|
|
|
|
// tests/system needs CI-runner host facilities (see docs/testing/taxonomy.md).
|
|
// It runs only when a caller names it, as `test:system` does; a bare `vitest`
|
|
// run leaves it out.
|
|
const systemTestsRequested = process.argv.some((argument) =>
|
|
argument.replaceAll("\\", "/").replace(/^\.\//u, "").startsWith("tests/system"),
|
|
);
|
|
|
|
export default defineConfig({
|
|
test: {
|
|
globals: false,
|
|
// 10-04. Vitest refuses `.only` only when CI is set; locally it quietly
|
|
// drops the rest of the file. Refuse it everywhere. Skipped and todo
|
|
// tests are failed by scripts/lib/no-skipped-tests-reporter.ts.
|
|
allowOnly: false,
|
|
setupFiles: ["./tests/setup.ts"],
|
|
restoreMocks: true,
|
|
clearMocks: true,
|
|
mockReset: true,
|
|
testTimeout: 10_000,
|
|
// Playwright specs (*.spec.ts) share tests/ but belong to Playwright.
|
|
include: ["tests/**/*.test.{ts,tsx}"],
|
|
exclude: [
|
|
...configDefaults.exclude,
|
|
".tmp/**",
|
|
// A git worktree inside the repository is a different checkout of a
|
|
// different branch. Running its tests against this checkout's config
|
|
// reports failures that belong to neither.
|
|
".worktrees/**",
|
|
"tests/fixtures/v8-coverage-counter-semantics/**",
|
|
...(systemTestsRequested ? [] : ["tests/system/**"]),
|
|
],
|
|
coverage: {
|
|
provider: "v8",
|
|
reportsDirectory: "artifacts/tests/coverage",
|
|
reporter: ["text", "json-summary", "lcov"],
|
|
include: ["src/**/*.{ts,tsx}"],
|
|
exclude: ["**/*.d.ts", "**/*.stories.*"],
|
|
},
|
|
},
|
|
});
|