Skip to content

Commit 3806903

Browse files
clydinalan-agius4
authored andcommitted
test(@angular/cli): allow invalid deps E2E to pass on release commits
When installing an outdated version of `@schematics/angular`, the package manager will also analyze installed dependencies. In the case of a release commit those dependencies are not yet on the npm registry and the outdated package install will fail. To remedy this situation, the outdated package and its two dependencies are published to the local test registry which allows the unreleased versions of the tooling packages to also be available to the package manager.
1 parent 9030c9e commit 3806903

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

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

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
1-
import { join } from 'path';
21
import { expectFileToMatch } from '../../utils/fs';
3-
import { ng } from '../../utils/process';
2+
import { ng, silentNpm } from '../../utils/process';
43
import { installPackage, uninstallPackage } from '../../utils/packages';
54
import { isPrereleaseCli } from '../../utils/project';
65

76
export default async function () {
8-
const componentDir = join('src', 'app', 'test-component');
7+
// Must publish old version to local registry to allow install. This is especially important
8+
// for release commits as npm will try to request tooling packages that are not on the npm registry yet
9+
const { stdout: stdoutPack1 } = await silentNpm(
10+
'pack',
11+
'@schematics/angular@7',
12+
'--registry=https://registry.npmjs.org',
13+
);
14+
await silentNpm('publish', stdoutPack1.trim(), '--registry=http://localhost:4873', '--tag=outdated');
15+
const { stdout: stdoutPack2 } = await silentNpm(
16+
'pack',
17+
'@angular-devkit/core@7',
18+
'--registry=https://registry.npmjs.org',
19+
);
20+
await silentNpm('publish', stdoutPack2.trim(), '--registry=http://localhost:4873', '--tag=outdated');
21+
const { stdout: stdoutPack3 } = await silentNpm(
22+
'pack',
23+
'@angular-devkit/schematics@7',
24+
'--registry=https://registry.npmjs.org',
25+
);
26+
await silentNpm('publish', stdoutPack3.trim(), '--registry=http://localhost:4873', '--tag=outdated');
927

10-
// Install old and incompatible version
11-
// Must directly use npm registry since old versions are not hosted locally
12-
await installPackage('@schematics/angular@7', 'https://registry.npmjs.org')
28+
// Install outdated and incompatible version
29+
await installPackage('@schematics/angular@7');
1330

14-
const tag = await isPrereleaseCli() ? '@next' : '';
31+
const tag = (await isPrereleaseCli()) ? '@next' : '';
1532
await ng('add', `@angular/material${tag}`);
1633
await expectFileToMatch('package.json', /@angular\/material/);
1734

0 commit comments

Comments
 (0)