Skip to content

Commit 711aa7f

Browse files
alan-agius4dgp1130
authored andcommitted
test(@angular/cli): force using NPM_CONFIG_legacy_peer_deps for ng add NPM 7 test
`NPM_CONFIG_legacy_peer_deps` is set to `true` during snapshot test runs https://github.com/angular/angular-cli/blob/177fa0d8c0076589fc12bce5ca5969606d541336/tests/legacy-cli/e2e/utils/packages.ts#L67-L69. This causes the `ng add @angular/localize` to not fail because of incorrect peer dependencies, which isn't the case when test against latest or next versions. With this change, we update this test to always set `NPM_CONFIG_legacy_peer_deps` to `true`.
1 parent 8074448 commit 711aa7f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { execSync } from 'child_process';
33
import { valid as validSemVer } from 'semver';
44
import { rimraf } from '../../utils/fs';
55
import { getActivePackageManager } from '../../utils/packages';
6-
import { ng, npm } from '../../utils/process';
6+
import { execWithEnv, ng, npm } from '../../utils/process';
77
import { isPrereleaseCli } from '../../utils/project';
88
import { expectToFail } from '../../utils/utils';
99

@@ -58,10 +58,12 @@ export default async function () {
5858
await npm('install', '--global', '[email protected]');
5959

6060
// Ensure `ng add` shows npm warning
61-
// The below command will fail with the below due to incorrect peerDeps
62-
const { message: stderrAdd } = await expectToFail(() =>
63-
ng('add', '@angular/localize', '--skip-confirmation'),
61+
const { stderr: stderrAdd } = await execWithEnv(
62+
'ng',
63+
['add', '@angular/localize', '--skip-confirmation'],
64+
{ ...process.env, 'NPM_CONFIG_legacy_peer_deps': 'true' },
6465
);
66+
6567
if (!stderrAdd.includes(warningText)) {
6668
throw new Error('ng add expected to show npm version warning.');
6769
}

0 commit comments

Comments
 (0)