Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

test(timing): match native runner behavior across Node [C7,V10]

Corey Olson3afbe1e9f11a
diff --git a/test/gate-timing-output.test.js b/test/gate-timing-output.test.js
index e7a3bbb2..67af0acf 100644
--- a/test/gate-timing-output.test.js
+++ b/test/gate-timing-output.test.js
@@ -41,10 +41,17 @@ test('timing profile reads direct and native TAP without inventing file rows [C7
const script = join(repo, 'timed', 'invocation.test.mjs');
writeFileSync(script, `import { writeFileSync } from 'node:fs'; import { test } from 'node:test'; writeFileSync(${JSON.stringify(trace)}, JSON.stringify({ argv: process.argv.slice(1), execArgv: process.execArgv, nodeOptions: process.env.NODE_OPTIONS ?? '' })); test('native default sample', () => {});`);
const command = 'node --test timed/invocation.test.mjs';
+ const bareOutput = execFileSync('/bin/sh', ['-c', command], { cwd: repo, encoding: 'utf8' });
+ assert.match(bareOutput, /native default sample/);
+ const callerInvocation = JSON.parse(readFileSync(trace, 'utf8'));
+ assert.deepEqual(callerInvocation.argv, [script]);
+ assert.equal(callerInvocation.nodeOptions, '');
+ // Node may supply default child flags; profiling must preserve the bare command's invocation.
const native = runProfiledShell(repo, command, { artifactDirectory: join(repo, 'artifacts'), persistLog: true, waitMs: 17 });
assert.equal(native.isGreen, true, native.output);
assert.match(native.output, /native default sample/);
- assert.deepEqual(JSON.parse(readFileSync(trace, 'utf8')), { argv: [script], execArgv: [], nodeOptions: '' });
+ assert.equal(/^TAP version \d+/mu.test(native.output), /^TAP version \d+/mu.test(bareOutput), 'profiling preserves the caller-selected output format');
+ assert.deepEqual(JSON.parse(readFileSync(trace, 'utf8')), callerInvocation);
assert.deepEqual(native.profile.files, [], 'default TAP does not provide a trustworthy file-duration row');
if (/^TAP version \d+/mu.test(native.output)) assert.ok(native.profile.tests.some(entry => entry.name.includes('native default sample')));
else assert.equal(native.profile.unavailable, 'per-test timing unavailable: output was not TAP or JUnit');
diff --git a/test/timing-reporter-fixture.js b/test/timing-reporter-fixture.js
index e78b2d30..754ea09c 100644
--- a/test/timing-reporter-fixture.js
+++ b/test/timing-reporter-fixture.js
@@ -13,7 +13,9 @@ export default async function* junit(events) {
for await (const event of events) {
const data = event.data ?? {};
if (event.type === 'test:summary' && data.file && Number.isFinite(data.duration_ms)) files.set(data.file, data.duration_ms);
- if (event.type === 'test:complete' && data.details?.type === 'test' && data.file && Number.isFinite(data.details.duration_ms)) {
+ // Node 22.13 omits the ordinary-test type; later versions emit it explicitly.
+ const ordinaryTest = data.details?.type === undefined || data.details.type === 'test';
+ if (event.type === 'test:complete' && ordinaryTest && data.file && Number.isFinite(data.details?.duration_ms)) {
if (data.line === 1 && data.column === 1 && resolve(data.name) === resolve(data.file)) continue;
tests.push({file:data.file,name:data.name,durationMs:data.details.duration_ms,passed:data.details.passed===true});
}