From 4f3db237900c6bed7e2f91936d147c8a6bb40971 Mon Sep 17 00:00:00 2001 From: gorankarlic Date: Sun, 1 Dec 2024 17:52:48 +0800 Subject: [PATCH] Add test for #55913 --- test/sequential/test-watch-mode.mjs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/sequential/test-watch-mode.mjs b/test/sequential/test-watch-mode.mjs index 39bc7223dffdfc..c669624dbf1165 100644 --- a/test/sequential/test-watch-mode.mjs +++ b/test/sequential/test-watch-mode.mjs @@ -242,6 +242,25 @@ describe('watch mode', { concurrency: !process.env.TEST_PARALLEL, timeout: 60_00 } }); + it('should not reload env variables when another file in the --env-file directory changes', async () => { + const envKey = `TEST_ENV_${Date.now()}`; + const dir = tmpdir.resolve('subdir0'); + const jsFile = createTmpFile(`console.log('ENV: ' + process.env.${envKey});`); + const envFile = createTmpFile(`${envKey}=value1`, '.env'); + const tmpFile = createTmpFile('', '.tmp'); + const { done, restart } = runInBackground({ args: ['--watch-path', dir, `--env-file=${envFile}`, jsFile] }); + + try { + await restart(); + writeFileSync(tmpFile, `${Date.now()}`); + + // Should not restart + await assert.rejects(restart(), {name: 'Error', message: 'Timed out waiting for restart'}); + } finally { + await done(); + } + }); + it('should watch changes to a failing file', async () => { const file = createTmpFile('throw new Error("fails");'); const { stderr, stdout } = await runWriteSucceed({