Commit 7b4c9e30ee1 for nodejs
commit 7b4c9e30ee15aa5492fa913c9213241a130d47c8
Author: Farid Zakaria <farid.m.zakaria@gmail.com>
Date: Mon Oct 26 16:56:48 2026 -0700
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>
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 {