Skip to content

Commit

Permalink
src: fix env var TZ test
Browse files Browse the repository at this point in the history
In some CI environments the TZ env var is set. Since a .env file won't
override that, we need to create an env where the test can still run by
deleting the TZ variable.
  • Loading branch information
philnash committed Sep 8, 2023
1 parent d91ebce commit 56f0868
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/parallel/test-dotenv-node-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ describe('.env supports NODE_OPTIONS', () => {
const code = `
require('assert')(new Date().toString().includes('Hawaii'))
`.trim();
// Some CI environments set TZ. Since an env file doesn't override existing
// environment variables, we need to delete it and then pass the env object
// as the environment to spawnPromisified.
const env = { ...process.env };
delete env.TZ;
const child = await common.spawnPromisified(
process.execPath,
[ `--env-file=${relativePath}`, '--eval', code ],
{ cwd: __dirname },
{ cwd: __dirname, env },
);
assert.strictEqual(child.stderr, '');
assert.strictEqual(child.code, 0);
Expand Down

0 comments on commit 56f0868

Please sign in to comment.