Skip to content

Commit 56f0868

Browse files
committed
src: fix env var TZ test
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.
1 parent d91ebce commit 56f0868

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/parallel/test-dotenv-node-options.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,15 @@ describe('.env supports NODE_OPTIONS', () => {
4848
const code = `
4949
require('assert')(new Date().toString().includes('Hawaii'))
5050
`.trim();
51+
// Some CI environments set TZ. Since an env file doesn't override existing
52+
// environment variables, we need to delete it and then pass the env object
53+
// as the environment to spawnPromisified.
54+
const env = { ...process.env };
55+
delete env.TZ;
5156
const child = await common.spawnPromisified(
5257
process.execPath,
5358
[ `--env-file=${relativePath}`, '--eval', code ],
54-
{ cwd: __dirname },
59+
{ cwd: __dirname, env },
5560
);
5661
assert.strictEqual(child.stderr, '');
5762
assert.strictEqual(child.code, 0);

0 commit comments

Comments
 (0)