Skip to content

Commit 37db1d2

Browse files
committed
test: use correct snapshot versions in add-pwa E2E test with yarn
When executing the add-pwa E2E test with Angular snapshots, the package versions need to be updated after the `ng add @angular/pwa` call to ensure that the correct version of `@angular/service-worker` is used. Yarn requires a different package installation strategy due to Yarn not always installing a new version of a github sha when directly adding an individual package.
1 parent 459aa2b commit 37db1d2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tests/legacy-cli/e2e/tests/commands/add/add-pwa.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { join } from 'path';
22
import { getGlobalVariable } from '../../../utils/env';
33
import { expectFileToExist, readFile, rimraf } from '../../../utils/fs';
4-
import { installPackage } from '../../../utils/packages';
4+
import { installWorkspacePackages } from '../../../utils/packages';
55
import { ng } from '../../../utils/process';
66
import { updateJsonFile } from '../../../utils/project';
77

@@ -26,19 +26,20 @@ export default async function () {
2626

2727
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
2828
if (isSnapshotBuild) {
29-
const packagesToInstall = [];
29+
let needInstall = false;
3030
await updateJsonFile('package.json', (packageJson) => {
3131
const dependencies = packageJson['dependencies'];
3232
// Iterate over all of the packages to update them to the snapshot version.
3333
for (const [name, version] of Object.entries(snapshots.dependencies)) {
3434
if (name in dependencies && dependencies[name] !== version) {
35-
packagesToInstall.push(version);
35+
dependencies[name] = version;
36+
needInstall = true;
3637
}
3738
}
3839
});
3940

40-
for (const pkg of packagesToInstall) {
41-
await installPackage(pkg);
41+
if (needInstall) {
42+
await installWorkspacePackages();
4243
}
4344
}
4445

0 commit comments

Comments
 (0)