From 2b10ceaef26ade918c06a4c24499d51a999a5119 Mon Sep 17 00:00:00 2001 From: Andreas Koestler Date: Tue, 28 Jul 2026 20:04:53 -0500 Subject: [PATCH] test(ts/cli): anchor stderr warning filter on Node's own prefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CLI run tests assert that stderr is empty, filtering out Node's one-time `ExperimentalWarning: globSync` notice. The filter matched `ExperimentalWarning` and `--trace-warnings` as unanchored substrings, so any line the CLI itself emitted containing either literal — a step name, a diagnostic, a hint — would be silently dropped from the assertions instead of failing them. Anchor on the prefixes of Node's own two-line notice instead, so only Node's notice is filtered and the CLI's own output is always asserted on. Co-Authored-By: Claude Opus 5 (1M context) --- typescript/packages/cli/tests/run.test.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/typescript/packages/cli/tests/run.test.ts b/typescript/packages/cli/tests/run.test.ts index 1e5a43ec..e7784843 100644 --- a/typescript/packages/cli/tests/run.test.ts +++ b/typescript/packages/cli/tests/run.test.ts @@ -15,10 +15,20 @@ function run(args: ReadonlyArray, cwd: string) { return spawnSync(process.execPath, [BIN_TS, ...args], { cwd, encoding: 'utf8' }) } +// Node's notice is two lines, each with a fixed prefix: +// +// (node:12345) ExperimentalWarning: globSync is an experimental feature ... +// (Use `node --trace-warnings ...` to show where the warning was created) +// +// Anchor on those prefixes rather than matching the text anywhere in the line, +// so a CLI-emitted line that happens to contain it is still asserted on. +const NODE_WARNING = /^\(node:\d+\) ExperimentalWarning:/ +const NODE_WARNING_HINT = /^\(Use `node --trace-warnings/ + function filterWarnings(stderr: string): string { return stderr .split('\n') - .filter((line) => !line.includes('ExperimentalWarning') && !line.includes('--trace-warnings')) + .filter((line) => !NODE_WARNING.test(line) && !NODE_WARNING_HINT.test(line)) .join('\n') .trim() }