test: deflake watch mode test for missing env file

The subtest watched all of tmpdir, so files created there by the
subtests running alongside it restarted the child and broke its
output. The fix is to watch a directory of its own instead to not
conflict.

Refs: https://github.com/nodejs/node/pull/66232
Assisted-by: Claude
Signed-off-by: Farid Zakaria <farid.m.zakaria@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67041
Reviewed-By: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
This commit is contained in:
Farid Zakaria authored and Antoine du Hamel committed 2026-11-16 10:09:56 +01:00
1 parent e396cb0bb3
commit b2f17a3732
1 file changed
+5 -3
+5 -3
View File
@@ -305,11 +305,13 @@ describe('watch mode', { concurrency: !process.env.TEST_PARALLEL, timeout: 60_00
});
it('should not crash when --env-file-if-exists points to a missing file', async () => {
const dir = tmpdir.resolve('subdir-missing-env-file');
mkdirSync(dir);
const envKey = `TEST_ENV_${Date.now()}`;
const jsFile = createTmpFile(`console.log('ENV: ' + process.env.${envKey});`);
const missingEnvFile = path.join(tmpdir.path, `missing-${Date.now()}.env`);
const jsFile = createTmpFile(`console.log('ENV: ' + process.env.${envKey});`, '.js', dir);
const missingEnvFile = path.join(dir, `missing-${Date.now()}.env`);
const { done, restart } = runInBackground({
args: ['--watch-path', tmpdir.path, `--env-file-if-exists=${missingEnvFile}`, jsFile],
args: ['--watch-path', dir, `--env-file-if-exists=${missingEnvFile}`, jsFile],
});
try {