Skip to content

Commit bbd7cf2

Browse files
committed
test: skip unscoped auth E2E update tests on unsupported package managers
This commit updates the `update-secure-registry` E2E test to skip unscoped authentication test cases when the active package manager is not Yarn, as other package managers may not support or correctly handle this setup in the test environment.
1 parent cb24c24 commit bbd7cf2

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

tests/e2e/tests/update/update-secure-registry.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { getActivePackageManager } from '../../utils/packages';
66
import assert from 'node:assert';
77

88
export default async function () {
9+
const packageManager = getActivePackageManager();
10+
const supportsUnscopedAuth = packageManager === 'yarn';
11+
912
// The environment variable has priority over the .npmrc
1013
delete process.env['NPM_CONFIG_REGISTRY'];
1114
const worksMessage = 'We analyzed your package.json';
@@ -16,10 +19,13 @@ export default async function () {
1619
}
1720

1821
// Valid authentication token
19-
await createNpmConfigForAuthentication(false);
20-
const { stdout: stdout1 } = await ng('update', ...extraArgs);
21-
if (!stdout1.includes(worksMessage)) {
22-
throw new Error(`Expected stdout to contain "${worksMessage}"`);
22+
23+
if (supportsUnscopedAuth) {
24+
await createNpmConfigForAuthentication(false);
25+
const { stdout: stdout1 } = await ng('update', ...extraArgs);
26+
if (!stdout1.includes(worksMessage)) {
27+
throw new Error(`Expected stdout to contain "${worksMessage}"`);
28+
}
2329
}
2430

2531
await createNpmConfigForAuthentication(true);
@@ -29,8 +35,11 @@ export default async function () {
2935
}
3036

3137
// Invalid authentication token
32-
await createNpmConfigForAuthentication(false, true);
33-
await expectToFail(() => ng('update', ...extraArgs));
38+
39+
if (supportsUnscopedAuth) {
40+
await createNpmConfigForAuthentication(false, true);
41+
await expectToFail(() => ng('update', ...extraArgs));
42+
}
3443

3544
await createNpmConfigForAuthentication(true, true);
3645
await expectToFail(() => ng('update', ...extraArgs));

0 commit comments

Comments
 (0)