Skip to content

Commit b2f17a3

Browse files
fzakariaaduh95
authored andcommitted
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: #66232 Assisted-by: Claude Signed-off-by: Farid Zakaria <farid.m.zakaria@gmail.com> PR-URL: #67041 Reviewed-By: Christian Aurich Zanettini Martins <christian.aurichzm@gmail.com>
1 parent e396cb0 commit b2f17a3

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎test/sequential/test-watch-mode.mjs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,13 @@ describe('watch mode', { concurrency: !process.env.TEST_PARALLEL, timeout: 60_00
305305
});
306306

307307
it('should not crash when --env-file-if-exists points to a missing file', async () => {
308+
const dir = tmpdir.resolve('subdir-missing-env-file');
309+
mkdirSync(dir);
308310
const envKey = `TEST_ENV_${Date.now()}`;
309-
const jsFile = createTmpFile(`console.log('ENV: ' + process.env.${envKey});`);
310-
const missingEnvFile = path.join(tmpdir.path, `missing-${Date.now()}.env`);
311+
const jsFile = createTmpFile(`console.log('ENV: ' + process.env.${envKey});`, '.js', dir);
312+
const missingEnvFile = path.join(dir, `missing-${Date.now()}.env`);
311313
const { done, restart } = runInBackground({
312-
args: ['--watch-path', tmpdir.path, `--env-file-if-exists=${missingEnvFile}`, jsFile],
314+
args: ['--watch-path', dir, `--env-file-if-exists=${missingEnvFile}`, jsFile],
313315
});
314316

315317
try {

0 commit comments

Comments
 (0)