Version
26.2.0
Platform
Subsystem
stream
What steps will reproduce the bug?
import { run } from 'node:test';
import { mkdtemp, writeFile, readFile } from 'node:fs/promises';
import { join } from 'node:path';
import { tmpdir } from 'node:os';
const cwd = await mkdtemp(join(tmpdir(), 'node-test-'));
const marker = join(cwd, 'ran');
await writeFile(join(cwd, 'test.js'), `
const test = require('node:test');
const { writeFileSync } = require('node:fs');
test('from cwd', () => writeFileSync(${JSON.stringify(marker)}, 'yes'));
`);
const ac = new AbortController();
const stream = run({
cwd,
watch: true,
isolation: 'none',
signal: ac.signal,
});
stream.on('data', ({ type }) => {
if (type === 'test:watch:drained') ac.abort();
});
for await (const _ of stream);
const ran = await readFile(marker, 'utf8').catch(() => 'no');
console.log({ ran });
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
run({ cwd, watch: true, isolation: 'none' }) should discover and execute tests from the supplied cwd, then report the result of those tests. In the repro, the cwd fixture should run and write the marker file.
What do you see instead?
The isolation-none watch child is spawned using the parent process argv while its working directory is changed to the supplied cwd. This can run the wrong entry point, recurse into the driver, or execute no intended cwd test, so the marker is not written.
Additional information
This is likely the same failure mode behind test-runner/test-run-watch-cwd-isolation-none: that test expects one pass from the fixture copied into tmpdir.path, but the implementation can spawn a watch child using the outer test’s argv instead of the cwd-scoped fixture. Depending on invocation and tmpdir state, it may report zero passes, fail recursively, or exit with code 1, making the CI failure flaky.
Version
26.2.0
Platform
Subsystem
stream
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
{ ran: 'yes' }run({ cwd, watch: true, isolation: 'none' })should discover and execute tests from the suppliedcwd, then report the result of those tests. In the repro, the cwd fixture should run and write the marker file.What do you see instead?
{ ran: 'no' }The isolation-none watch child is spawned using the parent process argv while its working directory is changed to the supplied
cwd. This can run the wrong entry point, recurse into the driver, or execute no intended cwd test, so the marker is not written.Additional information
This is likely the same failure mode behind
test-runner/test-run-watch-cwd-isolation-none: that test expects one pass from the fixture copied intotmpdir.path, but the implementation can spawn a watch child using the outer test’s argv instead of the cwd-scoped fixture. Depending on invocation and tmpdir state, it may report zero passes, fail recursively, or exit with code 1, making the CI failure flaky.