diff --git a/test/sequential/test-watch-mode.mjs b/test/sequential/test-watch-mode.mjs index 39bc7223dffdfc..52aea0877f0b78 100644 --- a/test/sequential/test-watch-mode.mjs +++ b/test/sequential/test-watch-mode.mjs @@ -242,6 +242,26 @@ 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 dir = tmpdir.resolve('subdir0'); + mkdirSync(dir); + const envKey = `TEST_ENV_${Date.now()}`; + const jsFile = createTmpFile(`console.log('ENV: ' + process.env.${envKey});`); + const envFile = createTmpFile(`${envKey}=value1`, '.env', dir); + const tmpFile = createTmpFile('', '.tmp', dir); + 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({