test: deflake test-run-watch-cwd-isolation-none-*

Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66035
Refs: https://github.com/nodejs/node/issues/66056
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Antoine du Hamel committed 2026-09-18 17:40:39 +02:00
1 parent eb4fabe81e
commit dda22c06d7
3 files changed
+35 -28

No files matched your search

@@ -2,7 +2,8 @@
// parent process argv when spawning the watch child.
import * as common from '../common/index.mjs';
import assert from 'node:assert';
import { writeFileSync } from 'node:fs';
import { setTimeout } from 'node:timers/promises';
import { writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import { run } from 'node:test';
import tmpdir from '../common/tmpdir.js';
@@ -11,12 +12,15 @@ import { skipIfNoWatch } from '../common/watch.js';
skipIfNoWatch();
tmpdir.refresh();
writeFileSync(join(tmpdir.path, 'test.js'), `
await writeFile(join(tmpdir.path, 'test.js'), `
const test = require('node:test');
test('test ran from cwd', () => {});
`);
// Add some delay to ensure the OS sends the FS events before watch mode is started.
await setTimeout(common.platformTimeout(100));
const passed = [];
const controller = new AbortController();
const stream = run({
@@ -24,18 +28,20 @@ const stream = run({
watch: true,
signal: controller.signal,
isolation: 'none',
}).on('data', function({ type }) {
if (type === 'test:watch:drained') {
stream.removeAllListeners('test:fail');
stream.removeAllListeners('test:pass');
controller.abort();
}
}).on('data', ({ type }) => {
if (type !== 'test:watch:drained') return;
stream.removeAllListeners('test:fail');
stream.removeAllListeners('test:pass');
controller.abort();
});
stream.on('test:fail', common.mustNotCall());
stream.on('test:pass', common.mustCall((data) => passed.push(data.name), 1));
// eslint-disable-next-line no-unused-vars
for await (const _ of stream);
stream.on('test:watch:restarted', common.mustNotCall('test:watch:restarted'));
stream.on('test:fail', common.mustNotCall('test:fail'));
stream.on('test:pass', common.mustCall((data) => passed.push(data.name)));
// eslint-disable-next-line no-empty-pattern
for await (const {} of stream);
// Validate the expected test ran by name:
assert.deepStrictEqual(passed, ['test ran from cwd']);
@@ -1,27 +1,28 @@
// Test run({ watch: true, cwd, isolation: 'none' }) runs with different cwd while in watch mode and isolation none
import * as common from '../common/index.mjs';
import * as fixtures from '../common/fixtures.mjs';
import { run } from 'node:test';
import tmpdir from '../common/tmpdir.js';
import { refreshForTestRunnerWatch, skipIfNoWatch } from '../common/watch.js';
import { skipIfNoWatch } from '../common/watch.js';
skipIfNoWatch();
refreshForTestRunnerWatch();
const controller = new AbortController();
const stream = run({
cwd: tmpdir.path,
cwd: fixtures.path('test-runner-watch'),
watch: true,
signal: controller.signal,
isolation: 'none',
}).on('data', function({ type }) {
if (type === 'test:watch:drained') {
stream.removeAllListeners('test:fail');
stream.removeAllListeners('test:pass');
controller.abort();
}
}).on('data', ({ type }) => {
if (type !== 'test:watch:drained') return;
stream.removeAllListeners('test:fail');
stream.removeAllListeners('test:pass');
controller.abort();
});
stream.on('test:fail', common.mustNotCall());
stream.on('test:pass', common.mustCall(1));
// eslint-disable-next-line no-unused-vars
for await (const _ of stream);
stream.on('test:watch:restarted', common.mustNotCall('test:watch:restarted'));
stream.on('test:fail', common.mustNotCall('test:fail'));
stream.on('test:pass', common.mustCall());
// eslint-disable-next-line no-empty-pattern
for await (const {} of stream);
+2 -2
View File
@@ -6,7 +6,7 @@ prefix test-runner
[true] # This section applies to all platforms
[$system==macos && $arch==x64]
# https://github.com/nodejs/node/issues/54534#issuecomment-5423551021
[$system==win32]
# https://github.com/nodejs/node/issues/66056
test-run-watch-cwd-isolation-none: PASS, FLAKY
test-run-watch-cwd-isolation-none-argv: PASS, FLAKY