Skip to content

Commit cfa3686

Browse files
authored
test(cli): deflake setup-claude.test.ts — silence console to stop stdout/report interleaving (#5959) (#6019)
Integrated into release/v3.8.44. Deflakes tests/unit/cli/setup-claude.test.ts (#5959) — verified in CI: setup-claude now passes in Unit Tests fast-path (2/2). Merged with --admin over two PRE-EXISTING base-reds proven independent of this test-only change (this PR only touches setup-claude.test.ts + CHANGELOG): - Fast Quality Gates → check:test-discovery: tests/unit/executors/{firecrawl-fetch,xai-executor}.test.ts are orphaned on release/v3.8.44 (added by #5793/#5800); the shard glob 'tests/unit/{api,...,ui}/**' omits 'executors'. Both blobs exist on the pristine base. - Unit Tests fast-path (2/2): tests/unit/settings-i18n-keys.test.ts → 'direct translation calls have English messages' fails on the pristine base too (unrelated i18n base-red).
1 parent 6756fa8 commit cfa3686

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ _TBD_
1717

1818
### 📝 Maintenance
1919

20+
- **test (deflake `setup-claude`):** `tests/unit/cli/setup-claude.test.ts` failed ~50% of runs with `Unable to deserialize cloned data due to invalid or unsupported version` at file teardown (all subtests passed), randomly reddening `Unit Tests fast-path (2/2)` / `Fast Quality Gates` across the PR→release queue. Root cause: `node --test` streams each file's report to the parent as V8-serialized frames on fd 1 (stdout), and the CLI helper under test (`syncClaudeProfilesFromModels`) prints progress via `console.log` — that stdout output interleaved with the serialized frames and corrupted the stream. The test now silences the stdout-writing `console` methods for the file's duration (no assertion inspects stdout), making it deterministic (15/15 green locally). ([#5959](https://github.com/diegosouzapw/OmniRoute/issues/5959))
21+
2022
- **API validation:** add a `validatedJsonBody(request, schema)` helper in `src/shared/validation/helpers.ts` that fuses JSON body parsing and Zod validation into a single call, returning either the type-narrowed data or a ready-to-return 400 `NextResponse` with the standard error envelope. Salvaged from the closed refactor PR #5075 (Tier 1 portable helper) with a focused 6-case regression test. Co-authored-by: KooshaPari <KooshaPari@users.noreply.github.com>
2123

2224
---

tests/unit/cli/setup-claude.test.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test } from "node:test";
1+
import { test, before, after } from "node:test";
22
import assert from "node:assert/strict";
33
import fs from "node:fs/promises";
44
import os from "node:os";
@@ -10,6 +10,27 @@ import {
1010
import { buildClaudeEnv, resolveLaunchTarget } from "../../../bin/cli/commands/launch.mjs";
1111
import { categoriseModel } from "../../../bin/cli/commands/setup-codex.mjs";
1212

13+
// #5959 — deflake: `node --test` runs each file in a child process that streams
14+
// its report back to the parent as V8-serialized frames on fd 1 (stdout). The CLI
15+
// helpers under test (`syncClaudeProfilesFromModels`) print progress via
16+
// `console.log`, and that stdout output interleaves with the serialized frames,
17+
// corrupting the stream — the parent then throws
18+
// "Unable to deserialize cloned data due to invalid or unsupported version" at
19+
// file teardown ~50% of runs (all subtests pass; only the file errors). No test
20+
// here asserts on stdout, so silence the stdout-writing console methods for the
21+
// duration of this file. Restored in `after` for good hygiene.
22+
const _console = { log: console.log, info: console.info, warn: console.warn };
23+
before(() => {
24+
console.log = () => {};
25+
console.info = () => {};
26+
console.warn = () => {};
27+
});
28+
after(() => {
29+
console.log = _console.log;
30+
console.info = _console.info;
31+
console.warn = _console.warn;
32+
});
33+
1334
// ── setup-claude profile generation ──────────────────────────────────────────
1435

1536
test("buildProfileSettings pins the model + base URL + gateway discovery", () => {

0 commit comments

Comments
 (0)