Skip to content

Commit ffa9a06

Browse files
committed
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.
1 parent d788263 commit ffa9a06

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

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

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ export default async function () {
1717
process.env.NPM_CONFIG_USERCONFIG = npmrc;
1818
process.env.NPM_CONFIG_PREFIX = npmModulesPrefix;
1919

20+
// Snapshot builds may contain versions that are not yet released (e.g., RC phase main branch).
21+
// In this case peer dependency ranges may not resolve causing npm 7+ to fail during tests.
22+
// To support this case, legacy peer dependency mode is enabled for snapshot builds.
23+
if (getGlobalVariable('argv')['ng-snapshots']) {
24+
process.env['NPM_CONFIG_legacy_peer_deps'] = 'true';
25+
}
26+
2027
// Configure the registry and prefix used within the test sandbox
2128
await writeFile(npmrc, `registry=${npmRegistry}\nprefix=${npmModulesPrefix}`);
2229
await mkdir(npmModulesPrefix);

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

-8
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export async function setRegistry(useTestRegistry: boolean): Promise<void> {
5050
: 'https://registry.npmjs.org';
5151

5252
const isCI = getGlobalVariable('ci');
53-
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
5453

5554
// Ensure local test registry is used when outside a project
5655
if (isCI) {
@@ -60,11 +59,4 @@ export async function setRegistry(useTestRegistry: boolean): Promise<void> {
6059
// Yarn supports both `NPM_CONFIG_REGISTRY` and `YARN_REGISTRY`.
6160
process.env['NPM_CONFIG_REGISTRY'] = url;
6261
}
63-
64-
// Snapshot builds may contain versions that are not yet released (e.g., RC phase main branch).
65-
// In this case peer dependency ranges may not resolve causing npm 7+ to fail during tests.
66-
// To support this case, legacy peer dependency mode is enabled for snapshot builds.
67-
if (isSnapshotBuild) {
68-
process.env['NPM_CONFIG_legacy_peer_deps'] = 'true';
69-
}
7062
}

0 commit comments

Comments
 (0)