Skip to content

Commit aae30d5

Browse files
jbedarddgp1130
authored andcommitted
test: suppress npm update warnings
1 parent 13eaa39 commit aae30d5

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

tests/legacy-cli/e2e/setup/002-npm-sandbox.ts

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export default async function () {
4141
setGlobalVariable('npm-global', npmModulesPrefix);
4242
setGlobalVariable('yarn-global', yarnModulesPrefix);
4343

44+
// Disable all update/notification related npm/yarn features such as the NPM updater notifier.
45+
// The NPM updater notifier may prevent the child process from closing until it timeouts after 3 minutes.
46+
process.env.NO_UPDATE_NOTIFIER = '1';
47+
process.env.NPM_CONFIG_UPDATE_NOTIFIER = 'false';
48+
4449
console.log(` Using "${npmModulesPrefix}" as e2e test global npm bin dir.`);
4550
console.log(` Using "${yarnModulesPrefix}" as e2e test global yarn bin dir.`);
4651
}

tests/legacy-cli/e2e/tests/misc/npm-7.ts

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as assert from 'assert';
2-
import { execSync } from 'child_process';
32
import { valid as validSemVer } from 'semver';
43
import { rimraf } from '../../utils/fs';
54
import { getActivePackageManager } from '../../utils/packages';
@@ -21,16 +20,7 @@ export default async function () {
2120
}
2221

2322
// Get current package manager version to restore after tests
24-
const initialVersionText = execSync('npm --version', {
25-
encoding: 'utf8',
26-
stdio: ['ignore', 'pipe', 'ignore'],
27-
env: {
28-
...process.env,
29-
// NPM updater notifier will prevent the child process from closing until it timeouts after 3 minutes.
30-
NO_UPDATE_NOTIFIER: '1',
31-
NPM_CONFIG_UPDATE_NOTIFIER: 'false',
32-
},
33-
}).trim();
23+
const initialVersionText = (await npm('--version')).stdout.trim();
3424
const initialVersion = validSemVer(initialVersionText);
3525
assert.ok(
3626
initialVersion,

tests/legacy-cli/e2e/utils/process.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface ExecOptions {
1616
cwd?: string;
1717
}
1818

19-
const NPM_CONFIG_RE = /^(npm_config_|yarn_)/i;
19+
const NPM_CONFIG_RE = /^(npm_config_|yarn_|no_update_notifier)/i;
2020

2121
let _processes: child_process.ChildProcess[] = [];
2222

0 commit comments

Comments
 (0)