From bd743706ae2200a4c3a0800e49f566882dc2c864 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Tue, 7 Jun 2022 13:13:49 -0400 Subject: [PATCH] test: ensure legacy peer dependency mode for E2E snapshot tests Snapshot builds may contain versions that are not yet released (e.g., RC phase main branch). In this case peer dependency ranges may not resolve causing npm 7+ to fail during tests. To support this case, legacy peer dependency mode is enabled for snapshot builds. --- tests/legacy-cli/e2e/setup/002-npm-sandbox.ts | 7 +++++++ tests/legacy-cli/e2e/utils/packages.ts | 8 -------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/legacy-cli/e2e/setup/002-npm-sandbox.ts b/tests/legacy-cli/e2e/setup/002-npm-sandbox.ts index 1d1824f25235..271980317b3b 100644 --- a/tests/legacy-cli/e2e/setup/002-npm-sandbox.ts +++ b/tests/legacy-cli/e2e/setup/002-npm-sandbox.ts @@ -17,6 +17,13 @@ export default async function () { process.env.NPM_CONFIG_USERCONFIG = npmrc; process.env.NPM_CONFIG_PREFIX = npmModulesPrefix; + // Snapshot builds may contain versions that are not yet released (e.g., RC phase main branch). + // In this case peer dependency ranges may not resolve causing npm 7+ to fail during tests. + // To support this case, legacy peer dependency mode is enabled for snapshot builds. + if (getGlobalVariable('argv')['ng-snapshots']) { + process.env['NPM_CONFIG_legacy_peer_deps'] = 'true'; + } + // Configure the registry and prefix used within the test sandbox await writeFile(npmrc, `registry=${npmRegistry}\nprefix=${npmModulesPrefix}`); await mkdir(npmModulesPrefix); diff --git a/tests/legacy-cli/e2e/utils/packages.ts b/tests/legacy-cli/e2e/utils/packages.ts index cc294acfcfa8..3c6476f14c3f 100644 --- a/tests/legacy-cli/e2e/utils/packages.ts +++ b/tests/legacy-cli/e2e/utils/packages.ts @@ -50,7 +50,6 @@ export async function setRegistry(useTestRegistry: boolean): Promise { : 'https://registry.npmjs.org'; const isCI = getGlobalVariable('ci'); - const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots']; // Ensure local test registry is used when outside a project if (isCI) { @@ -60,11 +59,4 @@ export async function setRegistry(useTestRegistry: boolean): Promise { // Yarn supports both `NPM_CONFIG_REGISTRY` and `YARN_REGISTRY`. process.env['NPM_CONFIG_REGISTRY'] = url; } - - // Snapshot builds may contain versions that are not yet released (e.g., RC phase main branch). - // In this case peer dependency ranges may not resolve causing npm 7+ to fail during tests. - // To support this case, legacy peer dependency mode is enabled for snapshot builds. - if (isSnapshotBuild) { - process.env['NPM_CONFIG_legacy_peer_deps'] = 'true'; - } }