Skip to content

Commit

Permalink
Add test for nodejs#55913
Browse files Browse the repository at this point in the history
  • Loading branch information
gorankarlic authored Dec 1, 2024
1 parent 3f9c6c0 commit 4f3db23
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/sequential/test-watch-mode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 4f3db23

Please sign in to comment.