Skip to content

Commit bd99a61

Browse files
committed
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`. (cherry picked from commit 711aa7f)
1 parent e1f8976 commit bd99a61

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
@@ -1,6 +1,6 @@
11
import { rimraf } from '../../utils/fs';
22
import { getActivePackageManager } from '../../utils/packages';
3-
import { ng, npm } from '../../utils/process';
3+
import { execWithEnv, ng, npm } from '../../utils/process';
44
import { isPrereleaseCli } from '../../utils/project';
55
import { expectToFail } from '../../utils/utils';
66

@@ -38,10 +38,12 @@ export default async function () {
3838
await npm('install', '--global', '[email protected]');
3939

4040
// Ensure `ng add` shows npm warning
41-
// The below command will fail with the below due to incorrect peerDeps
42-
const { message: stderrAdd } = await expectToFail(() =>
43-
ng('add', '@angular/localize', '--skip-confirmation'),
41+
const { stderr: stderrAdd } = await execWithEnv(
42+
'ng',
43+
['add', '@angular/localize', '--skip-confirmation'],
44+
{ ...process.env, 'NPM_CONFIG_legacy_peer_deps': 'true' },
4445
);
46+
4547
if (!stderrAdd.includes(warningText)) {
4648
throw new Error('ng add expected to show npm version warning.');
4749
}

0 commit comments

Comments
 (0)