Skip to content

Commit 34ff877

Browse files
committed
test: update NPM to latest version
This update upgrades the NPM version used for running end-to-end tests to the latest version. Notable changes include: - The `NPM_CONFIG__AUTH` configuration, which is tested here, no longer works for local packages as per [npm/cli#3985](npm/cli#3985). - NPM no longer supports unscoped auth. The configuration error "Invalid auth configuration found: `_auth` must be renamed to `//localhost:39521/:_auth` in the project config" will be encountered.
1 parent a90a783 commit 34ff877

File tree

4 files changed

+29
-43
lines changed

4 files changed

+29
-43
lines changed

tests/legacy-cli/e2e/setup/100-global-cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getActivePackageManager } from '../utils/packages';
33
import { globalNpm } from '../utils/process';
44

55
const PACKAGE_MANAGER_VERSION = {
6-
'npm': '7.24.0', // TODO: update to latest and fix tests.
6+
'npm': '10.8.1',
77
'yarn': '1.22.22',
88
'pnpm': '9.3.0',
99
'bun': '1.1.13',

tests/legacy-cli/e2e/tests/commands/add/npm-env-vars.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
import { expectFileNotToExist, expectFileToExist } from '../../../utils/fs';
2-
import { installWorkspacePackages } from '../../../utils/packages';
2+
import { getActivePackageManager, installWorkspacePackages } from '../../../utils/packages';
33
import { git, ng } from '../../../utils/process';
44
import { createNpmConfigForAuthentication } from '../../../utils/registry';
55
import { expectToFail } from '../../../utils/utils';
66

77
export default async function () {
88
// The environment variable has priority over the .npmrc
99
delete process.env['NPM_CONFIG_REGISTRY'];
10+
const isNpm = getActivePackageManager() === 'npm';
1011

1112
const command = ['add', '@angular/pwa', '--skip-confirmation'];
1213
await expectFileNotToExist('public/manifest.webmanifest');
1314

1415
// Works with unscoped registry authentication details
15-
await createNpmConfigForAuthentication(false);
16-
await ng(...command);
17-
await expectFileToExist('public/manifest.webmanifest');
18-
await git('clean', '-dxf');
19-
16+
if (!isNpm) {
17+
// NPM no longer support unscoped.
18+
await createNpmConfigForAuthentication(false);
19+
await ng(...command);
20+
await expectFileToExist('public/manifest.webmanifest');
21+
await git('clean', '-dxf');
22+
}
2023
// Works with scoped registry authentication details
2124
await expectFileNotToExist('public/manifest.webmanifest');
2225

@@ -25,8 +28,11 @@ export default async function () {
2528
await expectFileToExist('public/manifest.webmanifest');
2629

2730
// Invalid authentication token
28-
await createNpmConfigForAuthentication(false, true);
29-
await expectToFail(() => ng(...command));
31+
if (isNpm) {
32+
// NPM no longer support unscoped.
33+
await createNpmConfigForAuthentication(false, true);
34+
await expectToFail(() => ng(...command));
35+
}
3036

3137
await createNpmConfigForAuthentication(true, true);
3238
await expectToFail(() => ng(...command));

tests/legacy-cli/e2e/tests/misc/invalid-schematic-dependencies.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { join } from 'node:path';
12
import { expectFileToMatch } from '../../utils/fs';
23
import { execWithEnv, extractNpmEnv, ng, silentNpm } from '../../utils/process';
34
import { getActivePackageManager, installPackage, uninstallPackage } from '../../utils/packages';
45
import { isPrereleaseCli } from '../../utils/project';
5-
import { appendFile } from 'node:fs/promises';
6+
import { appendFile, writeFile } from 'node:fs/promises';
7+
import { getGlobalVariable } from '../../utils/env';
68

79
export default async function () {
810
// Must publish old version to local registry to allow install. This is especially important
@@ -29,15 +31,23 @@ export default async function () {
2931
}
3032

3133
async function publishOutdated(npmSpecifier: string): Promise<void> {
34+
const npmrc = join(getGlobalVariable('tmp-root'), '.npmrc-publish');
35+
const testRegistry = (getGlobalVariable('package-registry') as string).replace(/^\w+:/, '');
36+
await writeFile(
37+
npmrc,
38+
`
39+
${testRegistry.replace(/^https?:/, '')}/:_authToken=fake-secret
40+
`,
41+
);
42+
3243
const { stdout: stdoutPack } = await silentNpm(
3344
'pack',
3445
npmSpecifier,
3546
'--registry=https://registry.npmjs.org',
3647
);
48+
3749
await execWithEnv('npm', ['publish', stdoutPack.trim(), '--tag=outdated'], {
3850
...extractNpmEnv(),
39-
// Also set an auth token value for the local test registry which is required by npm 7+
40-
// even though it is never actually used.
41-
'NPM_CONFIG__AUTH': 'e2e-testing',
51+
'NPM_CONFIG_USERCONFIG': npmrc,
4252
});
4353
}

0 commit comments

Comments
 (0)