fix(ci): 게이트 실패 요약에 실패한 명령의 첫 실패 블록을 보인다 #67
@@ -1,7 +1,28 @@
|
||||
import { stripVTControlCharacters } from "node:util";
|
||||
|
||||
/** The most lines of the first failure block the summary quotes. */
|
||||
export const FIRST_FAILURE_MAX_LINES = 40;
|
||||
|
||||
// Where Playwright or vitest starts a failure block. Playwright numbers each
|
||||
// failed test (` 1) [chromium] › tests/x.spec.ts:3:1 › title`). vitest prints
|
||||
// a `Failed Suites 1` or `Failed Tests 2` rule and then a ` FAIL file > test`
|
||||
// line for each, and an `Unhandled Errors` rule when an error escaped the
|
||||
// tests (vitest 4.1, probed on desktop 2026-11-19).
|
||||
const PLAYWRIGHT_FAILURE = /^\s*\d+\) .*:\d+:\d+ › /u;
|
||||
const VITEST_FAILURES = /⎯ (Failed (Tests|Suites) \d+|Unhandled Errors) ⎯/u;
|
||||
// Where that block ends: the next failure, Playwright's count lines
|
||||
// (` 1 failed`, ` 68 passed (1.2m)`), vitest's `[1/6]` rule after each
|
||||
// failure or the bare rule after the unhandled errors.
|
||||
const PLAYWRIGHT_COUNT = /^\s*\d+ (failed|flaky|interrupted|skipped|did not run|passed)\b/u;
|
||||
const VITEST_FAILURE_END = /⎯\[\d+\/\d+\]⎯|^⎯+$/u;
|
||||
|
||||
/**
|
||||
* 1112/08-13. What a failed `ci:gate` prints to stderr: the gate, the command
|
||||
* that failed (or that none did), the log with the whole output, and the end
|
||||
* of that output, where the cause usually is.
|
||||
* that failed (or that none did), the log with the whole output, the first
|
||||
* Playwright or vitest failure block in that command's output, and the end
|
||||
* of the output. The end alone lost the assertion: a reporter prints counts,
|
||||
* attachments and its own stderr after the failure, and a drill runs more
|
||||
* commands after the test that failed (runner runs 371 and 376).
|
||||
*/
|
||||
export function formatGateFailure(input: Readonly<{
|
||||
gateId: string;
|
||||
@@ -11,15 +32,64 @@ export function formatGateFailure(input: Readonly<{
|
||||
output: readonly string[];
|
||||
tailLines?: number;
|
||||
}>): string {
|
||||
const tail = input.output
|
||||
const lines = input.output
|
||||
.flatMap((chunk) => chunk.split(/\r?\n/u))
|
||||
.filter((line) => line.trim() !== "")
|
||||
.slice(-(input.tailLines ?? 20));
|
||||
.filter((line) => line.trim() !== "");
|
||||
const tailStart = Math.max(0, lines.length - (input.tailLines ?? 20));
|
||||
const failure = firstFailureBlock(lines, input.failedCommand);
|
||||
// The part of the block that the last lines show anyway is not repeated.
|
||||
const quoted = failure
|
||||
? lines.slice(failure.start, Math.min(failure.end, tailStart))
|
||||
: [];
|
||||
const omitted = Math.max(0, quoted.length - FIRST_FAILURE_MAX_LINES);
|
||||
return [
|
||||
`${input.gateId} ${input.gateName}: FAIL`,
|
||||
` failed command: ${input.failedCommand ?? "none (a check outside the commands)"}`,
|
||||
` log: ${input.logPath}`,
|
||||
...(quoted.length > 0
|
||||
? [
|
||||
" first failure in the log:",
|
||||
...quoted.slice(0, FIRST_FAILURE_MAX_LINES).map((line) => ` ${line}`),
|
||||
...(omitted > 0 ? [` … ${omitted} more lines of this failure in the log`] : []),
|
||||
]
|
||||
: []),
|
||||
" last lines of the log:",
|
||||
...tail.map((line) => ` ${line}`),
|
||||
...lines.slice(tailStart).map((line) => ` ${line}`),
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Where the first reporter failure block after the failed command's own line
|
||||
* starts and ends (exclusive), as indexes into `lines`. An earlier command met
|
||||
* its expectation, so a failure it printed (a negative fixture) is not the
|
||||
* cause. Without a failed command there is no block.
|
||||
*/
|
||||
function firstFailureBlock(
|
||||
lines: readonly string[],
|
||||
failedCommand: string | undefined,
|
||||
): { start: number; end: number } | undefined {
|
||||
if (failedCommand === undefined) return undefined;
|
||||
const commandIndex = lines.lastIndexOf(failedCommand);
|
||||
if (commandIndex === -1) return undefined;
|
||||
const plain = lines.map((line) => stripVTControlCharacters(line));
|
||||
const endOf = (start: number, isEnd: (line: string) => boolean) => {
|
||||
let end = start + 1;
|
||||
while (end < plain.length && !isEnd(plain[end] ?? "")) end += 1;
|
||||
return end;
|
||||
};
|
||||
for (let start = commandIndex + 1; start < plain.length; start += 1) {
|
||||
const line = plain[start] ?? "";
|
||||
if (PLAYWRIGHT_FAILURE.test(line)) {
|
||||
// The next failure or a count line is not part of this one.
|
||||
return {
|
||||
start,
|
||||
end: endOf(start, (next) => PLAYWRIGHT_FAILURE.test(next) || PLAYWRIGHT_COUNT.test(next)),
|
||||
};
|
||||
}
|
||||
if (VITEST_FAILURES.test(line)) {
|
||||
// The closing rule is.
|
||||
return { start, end: Math.min(plain.length, endOf(start, (next) => VITEST_FAILURE_END.test(next)) + 1) };
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
$ corepack pnpm test:browser-capabilities
|
||||
|
||||
Running 69 tests using 6 workers
|
||||
|
||||
✓ 5 [chromium] › tests/browser-capabilities/local-draft-composition.spec.ts:10:1 › composes the local-draft feature over the real browser IndexedDB runtime (1.4s)
|
||||
✓ 67 [webkit] › tests/browser-capabilities/opfs-runtime.spec.ts:456:1 › 05-01 a reconcile in another tab skips a live put and the put stays readable (2.1s)
|
||||
✓ 68 [webkit] › tests/browser-capabilities/indexeddb-runtime.spec.ts:1078:1 › 05-03 deletes a partition's dataset for an authorized ACCOUNT_DELETION when its budget row is corrupt (1.6s)
|
||||
✓ 69 [webkit] › tests/browser-capabilities/indexeddb-runtime.spec.ts:1187:1 › 05-06 an older tab meets a schema a newer tab upgraded and goes online-only (1.6s)
|
||||
|
||||
|
||||
1) [chromium] › tests/browser-capabilities/cross-context-invalidation.spec.ts:223:1 › falls back to native localStorage events and removes the pulse during cleanup
|
||||
|
||||
Error: expect(received).toEqual(expected) // deep equality
|
||||
|
||||
- Expected - 8
|
||||
+ Received + 1
|
||||
|
||||
- Array [
|
||||
- Object {
|
||||
- "ordering": "NEXT",
|
||||
- "sequence": 1,
|
||||
- "topic": "sample-topic-alpha",
|
||||
- "transport": "STORAGE",
|
||||
- },
|
||||
- ]
|
||||
+ Array []
|
||||
|
||||
Call Log:
|
||||
- Timeout 5000ms exceeded while waiting on the predicate
|
||||
|
||||
247 | await expect
|
||||
248 | .poll(async () => (await snapshot(secondPage)).deliveries)
|
||||
> 249 | .toEqual([
|
||||
| ^
|
||||
250 | {
|
||||
251 | ordering: "NEXT",
|
||||
252 | sequence: 1,
|
||||
at /workspace/repo/tests/browser-capabilities/cross-context-invalidation.spec.ts:249:8
|
||||
|
||||
attachment #1: screenshot (image/png) ──────────────────────────────────────────────────────────
|
||||
artifacts/tests/browser-capabilities/results/cross-context-invalidation-f6965-es-the-pulse-during-cleanup-chromium/test-failed-1.png
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Error Context: artifacts/tests/browser-capabilities/results/cross-context-invalidation-f6965-es-the-pulse-during-cleanup-chromium/error-context.md
|
||||
|
||||
attachment #3: trace (application/zip) ─────────────────────────────────────────────────────────
|
||||
artifacts/tests/browser-capabilities/results/cross-context-invalidation-f6965-es-the-pulse-during-cleanup-chromium/trace.zip
|
||||
Usage:
|
||||
|
||||
pnpm exec playwright show-trace artifacts/tests/browser-capabilities/results/cross-context-invalidation-f6965-es-the-pulse-during-cleanup-chromium/trace.zip
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
1 failed
|
||||
[chromium] › tests/browser-capabilities/cross-context-invalidation.spec.ts:223:1 › falls back to native localStorage events and removes the pulse during cleanup
|
||||
68 passed (1.2m)
|
||||
[ELIFECYCLE] Command failed with exit code 1.
|
||||
|
||||
$ playwright test --config playwright.capabilities.config.ts
|
||||
[WebServer] $ node scripts/generate-product-feature-index.ts && vite --host 127.0.0.1 --port 43989 --strictPort
|
||||
|
||||
classification: UNEXPECTED_EXIT
|
||||
expectation failed: expected pass, exit=1, signal=none
|
||||
@@ -0,0 +1,108 @@
|
||||
$ corepack pnpm test:browser-file-storage-removal
|
||||
Typecheck inputs: PASS (tsconfig.app.json 309, tsconfig.node.json 315, tsconfig.service-worker.json 22, tsconfig.test.json 800)
|
||||
Static import graph: 310 modules, 862 dependencies, all imports resolved
|
||||
Architecture graph fixtures: 31 regression checks PASS
|
||||
TypeScript-only source policy: PASS (.storybook, scripts, src, tests, recipes; no fixture exceptions)
|
||||
[33m[2m✓[22m[39m passes when a product feature needs a product capability [33m 12423[2mms[22m[39m
|
||||
|
||||
[2m Test Files [22m [1m[31m1 failed[39m[22m[2m | [22m[1m[32m193 passed[39m[22m[90m (194)[39m
|
||||
[2m Tests [22m [1m[31m6 failed[39m[22m[2m | [22m[1m[32m2245 passed[39m[22m[90m (2251)[39m
|
||||
[2m Start at [22m 04:04:27
|
||||
[2m Duration [22m 38.86s[2m (transform 19.29s, setup 9.86s, import 62.35s, tests 240.80s, environment 2.10s)[22m
|
||||
|
||||
JUNIT report written to /workspace/repo/.tmp/browser-file-storage-runtime-removal-o54ad2/artifacts/tests/unit.xml
|
||||
$ corepack pnpm check:types:app && corepack pnpm check:types:node && corepack pnpm check:types:test && corepack pnpm check:types:service-worker && node scripts/check-typecheck-inputs.ts
|
||||
$ node scripts/generate-product-feature-index.ts && tsc --project tsconfig.app.json
|
||||
$ node scripts/generate-product-feature-index.ts && tsc --project tsconfig.node.json
|
||||
$ node scripts/generate-product-feature-index.ts && tsc --project tsconfig.test.json
|
||||
$ tsc --project tsconfig.service-worker.json
|
||||
$ eslint src scripts tests recipes .storybook vite.config.ts vitest.config.ts playwright*.config.ts --max-warnings=0
|
||||
$ node scripts/generate-product-feature-index.ts && node scripts/check-architecture.ts
|
||||
$ corepack pnpm test:runtime-schema && corepack pnpm test:unit && corepack pnpm test:contract && corepack pnpm test:component && corepack pnpm test:integration && node scripts/run-vitest.ts run tests/features tests/scripts tests/scale/browser-soak.contract.test.ts --reporter=default && corepack pnpm test:platform && corepack pnpm check:release-coherence && corepack pnpm test:recipes
|
||||
$ node scripts/run-vitest.ts run tests/runtime-schema --reporter=default --reporter=junit --outputFile.junit=artifacts/tests/runtime-schema.xml --passWithNoTests
|
||||
$ node scripts/run-vitest.ts run tests/unit --reporter=default --reporter=junit --outputFile.junit=artifacts/tests/unit.xml
|
||||
|
||||
[31m⎯⎯⎯⎯⎯⎯⎯[39m[1m[41m Failed Tests 6 [49m[22m[31m⎯⎯⎯⎯⎯⎯⎯[39m
|
||||
|
||||
[41m[1m FAIL [22m[49m tests/unit/test-evidence-source-rules.test.ts[2m > [22mtest evidence source rules[2m > [22mrejects a focused test
|
||||
[31m[1mAssertionError[22m: expected 'node:internal/fs/promises:637\n retu…' to contain 'focused test'[39m
|
||||
|
||||
[32m- Expected[39m
|
||||
[31m+ Received[39m
|
||||
|
||||
[32m- focused test[39m
|
||||
[31m+ node:internal/fs/promises:637[39m
|
||||
[31m+ return new FileHandle(await PromisePrototypeThen([39m
|
||||
[31m+ ^[39m
|
||||
[31m+[39m
|
||||
[31m+ Error: ENOENT: no such file or directory, open 'playwright.capabilities.config.ts'[39m
|
||||
[31m+ at async open (node:internal/fs/promises:637:25)[39m
|
||||
[31m+ at async readFile (node:internal/fs/promises:1269:14)[39m
|
||||
[31m+ at async missingForbidOnly (file:///workspace/repo/.tmp/browser-file-storage-runtime-removal-o54ad2/scripts/check-test-evidence.ts:378:11)[39m
|
||||
[31m+ at async file:///workspace/repo/.tmp/browser-file-storage-runtime-removal-o54ad2/scripts/check-test-evidence.ts:392:21 {[39m
|
||||
[31m+ errno: -2,[39m
|
||||
[31m+ code: 'ENOENT',[39m
|
||||
[31m+ syscall: 'open',[39m
|
||||
[31m+ path: 'playwright.capabilities.config.ts'[39m
|
||||
[31m+ }[39m
|
||||
[31m+[39m
|
||||
[31m+ Node.js v24.14.0[39m
|
||||
[31m+[39m
|
||||
|
||||
[36m [2m❯[22m tests/unit/test-evidence-source-rules.test.ts:[2m40:27[22m[39m
|
||||
[90m 38|[39m [35mconst[39m result [33m=[39m [34mcheckSource[39m([32m`[39m[36m${[39m[33mFORBIDDEN[39m[36m}[39m[32m/focused-test.fixture`[39m)[33m;[39m
|
||||
[90m 39|[39m [34mexpect[39m(result[33m.[39mstatus)[33m.[39m[34mtoBe[39m([34m1[39m)[33m;[39m
|
||||
[90m 40|[39m [34mexpect[39m(result[33m.[39mstderr)[33m.[39m[34mtoContain[39m([32m"focused test"[39m)[33m;[39m
|
||||
[90m |[39m [31m^[39m
|
||||
[90m 41|[39m }[33m,[39m [34mchildProcessTimeout[39m([34m1_333[39m))[33m;[39m
|
||||
[90m 42|[39m
|
||||
|
||||
[31m[2m⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/6]⎯[22m[39m
|
||||
|
||||
[90m 92|[39m
|
||||
|
||||
[31m[2m⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[5/6]⎯[22m[39m
|
||||
|
||||
[41m[1m FAIL [22m[49m tests/unit/test-evidence-source-rules.test.ts[2m > [22mtest evidence source rules[2m > [22maccepts a skip under an unexpired quarantine
|
||||
[31m[1mAssertionError[22m: expected 'node:internal/fs/promises:637\n retu…' to be '' // Object.is equality[39m
|
||||
|
||||
[32m- Expected[39m
|
||||
[31m+ Received[39m
|
||||
|
||||
[31m+ node:internal/fs/promises:637[39m
|
||||
[31m+ return new FileHandle(await PromisePrototypeThen([39m
|
||||
[31m+ ^[39m
|
||||
[31m+[39m
|
||||
[31m+ Error: ENOENT: no such file or directory, open 'playwright.capabilities.config.ts'[39m
|
||||
[31m+ at async open (node:internal/fs/promises:637:25)[39m
|
||||
[31m+ at async readFile (node:internal/fs/promises:1269:14)[39m
|
||||
[31m+ at async missingForbidOnly (file:///workspace/repo/.tmp/browser-file-storage-runtime-removal-o54ad2/scripts/check-test-evidence.ts:378:11)[39m
|
||||
[31m+ at async file:///workspace/repo/.tmp/browser-file-storage-runtime-removal-o54ad2/scripts/check-test-evidence.ts:392:21 {[39m
|
||||
[31m+ errno: -2,[39m
|
||||
[31m+ code: 'ENOENT',[39m
|
||||
[31m+ syscall: 'open',[39m
|
||||
[31m+ path: 'playwright.capabilities.config.ts'[39m
|
||||
[31m+ }[39m
|
||||
[31m+[39m
|
||||
[31m+ Node.js v24.14.0[39m
|
||||
[31m+[39m
|
||||
|
||||
[36m [2m❯[22m tests/unit/test-evidence-source-rules.test.ts:[2m108:27[22m[39m
|
||||
[90m106|[39m )[33m;[39m
|
||||
[90m107|[39m [35mconst[39m result [33m=[39m [34mcheckSource[39m(file)[33m;[39m
|
||||
[90m108|[39m [34mexpect[39m(result[33m.[39mstderr)[33m.[39m[34mtoBe[39m([32m""[39m)[33m;[39m
|
||||
[90m |[39m [31m^[39m
|
||||
[90m109|[39m [34mexpect[39m(result[33m.[39mstatus)[33m.[39m[34mtoBe[39m([34m0[39m)[33m;[39m
|
||||
[90m110|[39m }[33m,[39m [34mchildProcessTimeout[39m([34m842[39m))[33m;[39m
|
||||
|
||||
[31m[2m⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[6/6]⎯[22m[39m
|
||||
|
||||
$ node scripts/generate-product-feature-index.ts && node scripts/build-frontend.ts
|
||||
$ node scripts/generate-product-feature-index.ts && node scripts/check-optional-recipes.ts
|
||||
$ corepack pnpm check:artifact-schemas && node scripts/check-ci-contract.ts && corepack pnpm check:ci-workflow
|
||||
$ node scripts/generate-product-feature-index.ts && node scripts/generate-artifact-schemas.ts --check
|
||||
$ node scripts/generate-ci-workflow.ts --check
|
||||
Browser file/storage runtime removal failed: test
|
||||
|
||||
classification: UNEXPECTED_EXIT
|
||||
expectation failed: expected pass, exit=1, signal=none
|
||||
@@ -0,0 +1,103 @@
|
||||
$ corepack pnpm test:unit
|
||||
[1m[30m[46m RUN [49m[39m[22m [36mv4.1.12 [39m[90m/workspace/repo[39m
|
||||
|
||||
[31m❯[39m tests/unit/zz-probe-suite.test.ts [2m([22m[2m0 test[22m[2m)[22m
|
||||
[31m❯[39m tests/unit/zz-probe-unhandled.test.ts [2m([22m[2m3 tests[22m[2m | [22m[31m2 failed[39m[2m)[22m[32m 20[2mms[22m[39m
|
||||
[32m✓[39m passes but leaves an unhandled rejection[32m 13[2mms[22m[39m
|
||||
[31m [31m×[31m fails one[39m[32m 5[2mms[22m[39m
|
||||
[31m [31m×[31m fails two[39m[32m 1[2mms[22m[39m
|
||||
|
||||
[31m⎯⎯⎯⎯⎯⎯[39m[1m[41m Failed Suites 1 [49m[22m[31m⎯⎯⎯⎯⎯⎯⎯[39m
|
||||
|
||||
[41m[1m FAIL [22m[49m tests/unit/zz-probe-suite.test.ts[2m [ tests/unit/zz-probe-suite.test.ts ][22m
|
||||
[31m[1mError[22m: probe suite failure at import[39m
|
||||
[36m [2m❯[22m tests/unit/zz-probe-suite.test.ts:[2m3:7[22m[39m
|
||||
[90m 1|[39m [35mimport[39m { it } [35mfrom[39m [32m"vitest"[39m[33m;[39m
|
||||
[90m 2|[39m
|
||||
[90m 3|[39m [35mthrow[39m [35mnew[39m [33mError[39m([32m"probe suite failure at import"[39m)[33m;[39m
|
||||
[90m |[39m [31m^[39m
|
||||
[90m 4|[39m
|
||||
[90m 5|[39m [34mit[39m([32m"never runs"[39m[33m,[39m () [33m=>[39m {})[33m;[39m
|
||||
|
||||
[31m[2m⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/3]⎯[22m[39m
|
||||
|
||||
|
||||
[31m⎯⎯⎯⎯⎯⎯⎯[39m[1m[41m Failed Tests 2 [49m[22m[31m⎯⎯⎯⎯⎯⎯⎯[39m
|
||||
|
||||
[41m[1m FAIL [22m[49m tests/unit/zz-probe-unhandled.test.ts[2m > [22mfails one
|
||||
[31m[1mAssertionError[22m: expected { a: 1 } to deeply equal { a: 2 }[39m
|
||||
|
||||
[32m- Expected[39m
|
||||
[31m+ Received[39m
|
||||
|
||||
[2m {[22m
|
||||
[32m- "a": 2,[39m
|
||||
[31m+ "a": 1,[39m
|
||||
[2m }[22m
|
||||
|
||||
[36m [2m❯[22m tests/unit/zz-probe-unhandled.test.ts:[2m10:20[22m[39m
|
||||
[90m 8|[39m
|
||||
[90m 9|[39m [34mit[39m([32m"fails one"[39m[33m,[39m () [33m=>[39m {
|
||||
[90m 10|[39m [34mexpect[39m({ a[33m:[39m [34m1[39m })[33m.[39m[34mtoEqual[39m({ a[33m:[39m [34m2[39m })[33m;[39m
|
||||
[90m |[39m [31m^[39m
|
||||
[90m 11|[39m })[33m;[39m
|
||||
[90m 12|[39m
|
||||
|
||||
[31m[2m⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/3]⎯[22m[39m
|
||||
|
||||
[41m[1m FAIL [22m[49m tests/unit/zz-probe-unhandled.test.ts[2m > [22mfails two
|
||||
[31m[1mAssertionError[22m: expected [ 1, 2 ] to deeply equal [ 1, 3 ][39m
|
||||
|
||||
[32m- Expected[39m
|
||||
[31m+ Received[39m
|
||||
|
||||
[2m [[22m
|
||||
[2m 1,[22m
|
||||
[32m- 3,[39m
|
||||
[31m+ 2,[39m
|
||||
[2m ][22m
|
||||
|
||||
[36m [2m❯[22m tests/unit/zz-probe-unhandled.test.ts:[2m14:18[22m[39m
|
||||
[90m 12|[39m
|
||||
[90m 13|[39m [34mit[39m([32m"fails two"[39m[33m,[39m () [33m=>[39m {
|
||||
[90m 14|[39m [34mexpect[39m([[34m1[39m[33m,[39m [34m2[39m])[33m.[39m[34mtoEqual[39m([[34m1[39m[33m,[39m [34m3[39m])[33m;[39m
|
||||
[90m |[39m [31m^[39m
|
||||
[90m 15|[39m })[33m;[39m
|
||||
[90m 16|[39m
|
||||
|
||||
[31m[2m⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[3/3]⎯[22m[39m
|
||||
|
||||
[31m⎯⎯⎯⎯⎯⎯[39m[1m[41m Unhandled Errors [49m[22m[31m⎯⎯⎯⎯⎯⎯[39m
|
||||
[31m[1m
|
||||
Vitest caught 1 unhandled error during the test run.
|
||||
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.[22m[39m
|
||||
|
||||
[31m⎯⎯⎯⎯[39m[1m[41m Unhandled Rejection [49m[22m[31m⎯⎯⎯⎯⎯[39m
|
||||
[31m[1mError[22m: probe unhandled rejection[39m
|
||||
[36m [2m❯[22m tests/unit/zz-probe-unhandled.test.ts:[2m4:23[22m[39m
|
||||
[90m 2|[39m
|
||||
[90m 3|[39m [34mit[39m([32m"passes but leaves an unhandled rejection"[39m[33m,[39m [35masync[39m () [33m=>[39m {
|
||||
[90m 4|[39m [35mvoid[39m [33mPromise[39m[33m.[39m[34mreject[39m([35mnew[39m [33mError[39m([32m"probe unhandled rejection"[39m))[33m;[39m
|
||||
[90m |[39m [31m^[39m
|
||||
[90m 5|[39m [35mawait[39m [35mnew[39m [33mPromise[39m((resolve) [33m=>[39m [34msetTimeout[39m(resolve[33m,[39m [34m10[39m))[33m;[39m
|
||||
[90m 6|[39m [34mexpect[39m([34m1[39m)[33m.[39m[34mtoBe[39m([34m1[39m)[33m;[39m
|
||||
[90m [2m❯[22m node_modules/.pnpm/@vitest+runner@4.1.12/node_modules/@vitest/runner/dist/chunk-artifact.js:[2m302:11[22m[39m
|
||||
[90m [2m❯[22m node_modules/.pnpm/@vitest+runner@4.1.12/node_modules/@vitest/runner/dist/chunk-artifact.js:[2m1903:26[22m[39m
|
||||
[90m [2m❯[22m node_modules/.pnpm/@vitest+runner@4.1.12/node_modules/@vitest/runner/dist/chunk-artifact.js:[2m2326:20[22m[39m
|
||||
[90m [2m❯[22m runWithCancel node_modules/.pnpm/@vitest+runner@4.1.12/node_modules/@vitest/runner/dist/chunk-artifact.js:[2m2323:10[22m[39m
|
||||
[90m [2m❯[22m node_modules/.pnpm/@vitest+runner@4.1.12/node_modules/@vitest/runner/dist/chunk-artifact.js:[2m2305:20[22m[39m
|
||||
[90m [2m❯[22m runWithTimeout node_modules/.pnpm/@vitest+runner@4.1.12/node_modules/@vitest/runner/dist/chunk-artifact.js:[2m2272:10[22m[39m
|
||||
[90m [2m❯[22m node_modules/.pnpm/@vitest+runner@4.1.12/node_modules/@vitest/runner/dist/chunk-artifact.js:[2m2956:64[22m[39m
|
||||
|
||||
[31mThis error originated in "[1mtests/unit/zz-probe-unhandled.test.ts[22m" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.[39m
|
||||
[31mThe latest test that might've caused the error is "[1mpasses but leaves an unhandled rejection[22m". It might mean one of the following:
|
||||
- The error was thrown, while Vitest was running this test.
|
||||
- If the error occurred after the test had been completed, this was the last documented test before it was thrown.[39m
|
||||
[31m⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[39m
|
||||
|
||||
|
||||
[2m Test Files [22m [1m[31m2 failed[39m[22m[90m (2)[39m
|
||||
[2m Tests [22m [1m[31m2 failed[39m[22m[2m | [22m[1m[32m1 passed[39m[22m[90m (3)[39m
|
||||
[2m Errors [22m [1m[31m1 error[39m[22m
|
||||
[2m Start at [22m 18:03:15
|
||||
[2m Duration [22m 160ms[2m (transform 27ms, setup 42ms, import 5ms, tests 20ms, environment 0ms)[22m
|
||||
@@ -2,11 +2,12 @@ import { spawnSync } from "node:child_process";
|
||||
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
import { stripVTControlCharacters } from "node:util";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { loadCiGateContract } from "../../scripts/contracts/ci-gates.ts";
|
||||
import { formatGateFailure } from "../../scripts/lib/ci-gate-failure.ts";
|
||||
import { FIRST_FAILURE_MAX_LINES, formatGateFailure } from "../../scripts/lib/ci-gate-failure.ts";
|
||||
import { FIXTURE_PNPM_ENVIRONMENT } from "../../scripts/lib/fixture-node-modules.ts";
|
||||
import { PR_BASE_REF_VARIABLE } from "../../scripts/lib/pr-gate-selection.ts";
|
||||
import { childProcessTimeout } from "../helpers/child-process-timeout.ts";
|
||||
@@ -70,6 +71,200 @@ describe("formatGateFailure", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// Runner runs 371 and 376. The last 20 lines held the reporter's summary, the
|
||||
// pnpm stderr and the classification, not the assertion: run 371's FE-GATE-008
|
||||
// job log showed the code frame of a failed `expect.poll(...).toEqual(...)`
|
||||
// but neither the expected nor the received value, and run 376's FE-GATE-030
|
||||
// lost the vitest `FAIL` line and its ENOENT to the removal drill's later
|
||||
// commands. Two fixtures are those gate logs (artifacts/quality/gates/), cut
|
||||
// down, with the checkout path shortened; the third is vitest 4.1's own output
|
||||
// for a suite that fails to load, two failed tests and an unhandled rejection
|
||||
// (probed on desktop 2026-11-19).
|
||||
describe("formatGateFailure with a reporter's failure block", () => {
|
||||
const fixture = (name: string) =>
|
||||
readFile(path.join("tests/fixtures/ci-gate-failure", name), "utf8");
|
||||
// The reporters color their output; the assertions read the text.
|
||||
const plain = (text: string) => stripVTControlCharacters(text);
|
||||
/** The quoted first failure, without its four-space indent. */
|
||||
const firstFailure = (text: string) => {
|
||||
const lines = plain(text).split("\n");
|
||||
const from = lines.indexOf(" first failure in the log:");
|
||||
const to = lines.indexOf(" last lines of the log:");
|
||||
return from === -1 ? [] : lines.slice(from + 1, to).map((line) => line.slice(4));
|
||||
};
|
||||
// Lines a reporter prints after the failures, enough to push them out of
|
||||
// the last 20 lines.
|
||||
const laterOutput = Array.from({ length: 25 }, (_, index) => `[WebServer] request ${index + 1}`);
|
||||
const passedCommand = [
|
||||
"$ corepack pnpm test:e2e",
|
||||
" 189 passed (1.8m)",
|
||||
"classification: EXPECTED_PASS",
|
||||
];
|
||||
const failing = (command: string, output: readonly string[]) =>
|
||||
formatGateFailure({
|
||||
gateId: "FE-GATE-008",
|
||||
gateName: "e2e",
|
||||
logPath: "artifacts/quality/gates/FE-GATE-008.txt",
|
||||
failedCommand: command,
|
||||
output: [command, ...output],
|
||||
});
|
||||
|
||||
it("quotes the first Playwright failure with its expected and received values", async () => {
|
||||
const text = formatGateFailure({
|
||||
gateId: "FE-GATE-008",
|
||||
gateName: "e2e",
|
||||
logPath: "artifacts/quality/gates/FE-GATE-008.txt",
|
||||
failedCommand: "$ corepack pnpm test:browser-capabilities",
|
||||
output: [...passedCommand, await fixture("playwright-assertion.txt")],
|
||||
});
|
||||
|
||||
expect(text).toContain(
|
||||
"1) [chromium] › tests/browser-capabilities/cross-context-invalidation.spec.ts:223:1",
|
||||
);
|
||||
expect(text).toContain("Error: expect(received).toEqual(expected) // deep equality");
|
||||
expect(text).toContain("- Expected - 8");
|
||||
expect(text).toContain("+ Received + 1");
|
||||
expect(text).toContain('- "sequence": 1,');
|
||||
expect(text).toContain("+ Array []");
|
||||
// The end of the log is still there.
|
||||
expect(text).toContain("expectation failed: expected pass, exit=1, signal=none");
|
||||
});
|
||||
|
||||
it("quotes the first vitest failure that a drill printed before its later commands", async () => {
|
||||
const text = plain(formatGateFailure({
|
||||
gateId: "FE-GATE-030",
|
||||
gateName: "optional-removability",
|
||||
logPath: "artifacts/quality/gates/FE-GATE-030.txt",
|
||||
failedCommand: "$ corepack pnpm test:browser-file-storage-removal",
|
||||
output: [await fixture("vitest-in-removal-drill.txt")],
|
||||
}));
|
||||
|
||||
expect(text).toContain(
|
||||
"FAIL tests/unit/test-evidence-source-rules.test.ts > test evidence source rules > rejects a focused test",
|
||||
);
|
||||
expect(text).toContain("AssertionError: expected 'node:internal/fs/promises:637");
|
||||
expect(text).toContain("to contain 'focused test'");
|
||||
expect(text).toContain(
|
||||
"Error: ENOENT: no such file or directory, open 'playwright.capabilities.config.ts'",
|
||||
);
|
||||
expect(text).toContain("Browser file/storage runtime removal failed: test");
|
||||
});
|
||||
|
||||
it("ends a Playwright failure where the next one starts", () => {
|
||||
const quoted = firstFailure(failing("$ corepack pnpm test:e2e", [
|
||||
" 1) [chromium] › tests/e2e/first.spec.ts:3:1 › fails first",
|
||||
" Error: the first failure",
|
||||
" 2) [firefox] › tests/e2e/second.spec.ts:5:1 › fails second",
|
||||
" Error: the second failure",
|
||||
" 2 failed",
|
||||
...laterOutput,
|
||||
]));
|
||||
|
||||
expect(quoted).toEqual([
|
||||
" 1) [chromium] › tests/e2e/first.spec.ts:3:1 › fails first",
|
||||
" Error: the first failure",
|
||||
]);
|
||||
});
|
||||
|
||||
it("ends a Playwright failure before the count lines", () => {
|
||||
const quoted = firstFailure(failing("$ corepack pnpm test:e2e", [
|
||||
" 1) [chromium] › tests/e2e/only.spec.ts:3:1 › fails",
|
||||
" Error: the only failure",
|
||||
" 1 failed",
|
||||
" [chromium] › tests/e2e/only.spec.ts:3:1 › fails",
|
||||
" 68 passed (1.2m)",
|
||||
...laterOutput,
|
||||
]));
|
||||
|
||||
expect(quoted).toEqual([
|
||||
" 1) [chromium] › tests/e2e/only.spec.ts:3:1 › fails",
|
||||
" Error: the only failure",
|
||||
]);
|
||||
});
|
||||
|
||||
it("ends a vitest failure with its closing rule", async () => {
|
||||
const quoted = firstFailure(formatGateFailure({
|
||||
gateId: "FE-GATE-005",
|
||||
gateName: "unit",
|
||||
logPath: "artifacts/quality/gates/FE-GATE-005.txt",
|
||||
failedCommand: "$ corepack pnpm test:unit",
|
||||
output: [await fixture("vitest-suites-tests-unhandled.txt"), ...laterOutput],
|
||||
}));
|
||||
|
||||
expect(quoted[0]).toMatch(/⎯ Failed Suites 1 ⎯/u);
|
||||
expect(quoted).toContain("Error: probe suite failure at import");
|
||||
expect(quoted.at(-1)).toMatch(/⎯\[1\/3\]⎯$/u);
|
||||
expect(quoted.join("\n")).not.toContain("fails one");
|
||||
});
|
||||
|
||||
it("quotes vitest's unhandled errors when every test passed", async () => {
|
||||
const probe = (await fixture("vitest-suites-tests-unhandled.txt")).split("\n");
|
||||
const unhandled = probe.findIndex((line) => plain(line).includes("⎯ Unhandled Errors ⎯"));
|
||||
expect(unhandled).toBeGreaterThan(0);
|
||||
const quoted = firstFailure(failing("$ corepack pnpm test:unit", [
|
||||
" ✓ tests/unit/passes.test.ts (1 test) 13ms",
|
||||
...probe.slice(unhandled),
|
||||
...laterOutput,
|
||||
]));
|
||||
|
||||
expect(quoted[0]).toMatch(/⎯ Unhandled Errors ⎯/u);
|
||||
expect(quoted).toContain("Error: probe unhandled rejection");
|
||||
expect(quoted.at(-1)).toMatch(/^⎯+$/u);
|
||||
expect(quoted.join("\n")).not.toContain("Test Files");
|
||||
});
|
||||
|
||||
it("looks only in the output of the command that failed", async () => {
|
||||
const text = formatGateFailure({
|
||||
gateId: "FE-GATE-008",
|
||||
gateName: "e2e",
|
||||
logPath: "artifacts/quality/gates/FE-GATE-008.txt",
|
||||
failedCommand: "$ corepack pnpm test:browser-capabilities",
|
||||
output: [
|
||||
// A negative fixture fails on purpose and meets its expectation.
|
||||
"$ corepack pnpm check:fails-on-purpose",
|
||||
" 1) [chromium] › tests/e2e/negative.spec.ts:3:1 › fails on purpose",
|
||||
" Error: a failure this command was expected to print",
|
||||
" 1 failed",
|
||||
"classification: EXPECTED_FAILURE",
|
||||
await fixture("playwright-assertion.txt"),
|
||||
],
|
||||
});
|
||||
|
||||
expect(text).not.toContain("a failure this command was expected to print");
|
||||
expect(text).toContain("Error: expect(received).toEqual(expected) // deep equality");
|
||||
});
|
||||
|
||||
it("bounds a long failure and says how much more the log holds", () => {
|
||||
const diff = Array.from({ length: 120 }, (_, index) => ` + line ${index + 1}`);
|
||||
const block = [
|
||||
" 1) [chromium] › tests/e2e/long.spec.ts:3:1 › prints a long diff",
|
||||
" Error: expect(received).toEqual(expected) // deep equality",
|
||||
...diff,
|
||||
];
|
||||
const text = failing("$ corepack pnpm test:e2e", [...block, " 1 failed", ...laterOutput]);
|
||||
const quoted = firstFailure(text);
|
||||
|
||||
expect(quoted).toEqual([
|
||||
...block.slice(0, FIRST_FAILURE_MAX_LINES),
|
||||
`… ${block.length - FIRST_FAILURE_MAX_LINES} more lines of this failure in the log`,
|
||||
]);
|
||||
// Three heading lines, the quoted failure, the end of the log.
|
||||
expect(text.split("\n")).toHaveLength(3 + 1 + FIRST_FAILURE_MAX_LINES + 1 + 1 + 20);
|
||||
});
|
||||
|
||||
it("does not repeat a failure that the last lines already show", () => {
|
||||
const text = failing("$ corepack pnpm test:e2e", [
|
||||
" 1) [chromium] › tests/e2e/short.spec.ts:3:1 › fails",
|
||||
" Error: the one failure",
|
||||
" 1 failed",
|
||||
"classification: UNEXPECTED_EXIT",
|
||||
]);
|
||||
|
||||
expect(firstFailure(text)).toEqual([]);
|
||||
expect(text.split("Error: the one failure").length - 1).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
// round9 confirm review. The runner itself hands the failed command to that
|
||||
// text: a gate whose one command fails names it, its log and its last line.
|
||||
// Same temp-root runner as tests/system/ci-runner/ci-evidence-freshness.test.ts,
|
||||
|
||||
Reference in New Issue
Block a user