From b2f17a37329e7fcb9f9b094b705a338429cfd31f Mon Sep 17 00:00:00 2001 From: Farid Zakaria Date: Mon, 26 Oct 2026 16:56:48 -0700 Subject: [PATCH] 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 PR-URL: https://github.com/nodejs/node/pull/67041 Reviewed-By: Christian Aurich Zanettini Martins --- test/sequential/test-watch-mode.mjs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/sequential/test-watch-mode.mjs b/test/sequential/test-watch-mode.mjs index 6b7d9f02194..f88ac43c458 100644 --- a/test/sequential/test-watch-mode.mjs +++ b/test/sequential/test-watch-mode.mjs @@ -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 {