Skip to content

test: ensure legacy peer dependency mode for E2E snapshot tests #23311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/legacy-cli/e2e/setup/002-npm-sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 0 additions & 8 deletions tests/legacy-cli/e2e/utils/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export async function setRegistry(useTestRegistry: boolean): Promise<void> {
: '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) {
Expand All @@ -60,11 +59,4 @@ export async function setRegistry(useTestRegistry: boolean): Promise<void> {
// 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';
}
}