Skip to content

Commit 7ce88c7

Browse files
jbedardclydin
authored andcommitted
test: ensure test registry is used by default
1 parent 1f66ede commit 7ce88c7

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

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

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export default async function () {
1616
// isolated within this e2e test invocation.
1717
process.env.NPM_CONFIG_USERCONFIG = npmrc;
1818
process.env.NPM_CONFIG_PREFIX = npmModulesPrefix;
19+
process.env.NPM_CONFIG_REGISTRY = npmRegistry;
1920

2021
// Snapshot builds may contain versions that are not yet released (e.g., RC phase main branch).
2122
// In this case peer dependency ranges may not resolve causing npm 7+ to fail during tests.

tests/legacy-cli/e2e/tests/commands/add/registry-option.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import { getGlobalVariable } from '../../../utils/env';
2-
import { expectFileToExist, writeMultipleFiles } from '../../../utils/fs';
2+
import { expectFileToExist } from '../../../utils/fs';
33
import { ng } from '../../../utils/process';
44
import { expectToFail } from '../../../utils/utils';
55

66
export default async function () {
77
const testRegistry = getGlobalVariable('package-registry');
88

9-
// Setup an invalid registry
10-
await writeMultipleFiles({
11-
'.npmrc': 'registry=http://127.0.0.1:9999',
12-
});
13-
14-
// The environment variable has priority over the .npmrc
15-
delete process.env['NPM_CONFIG_REGISTRY'];
9+
// Set an invalid registry
10+
process.env['NPM_CONFIG_REGISTRY'] = 'http://127.0.0.1:9999';
1611

1712
await expectToFail(() => ng('add', '@angular/pwa', '--skip-confirmation'));
1813

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

+2-7
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ export async function setRegistry(useTestRegistry: boolean): Promise<void> {
5252
const isCI = getGlobalVariable('ci');
5353

5454
// Ensure local test registry is used when outside a project
55-
if (isCI) {
56-
// Safe to set a user configuration on CI
57-
await npm('config', 'set', 'registry', url);
58-
} else {
59-
// Yarn supports both `NPM_CONFIG_REGISTRY` and `YARN_REGISTRY`.
60-
process.env['NPM_CONFIG_REGISTRY'] = url;
61-
}
55+
// Yarn supports both `NPM_CONFIG_REGISTRY` and `YARN_REGISTRY`.
56+
process.env['NPM_CONFIG_REGISTRY'] = url;
6257
}

0 commit comments

Comments
 (0)