Skip to content

Commit 7a0638f

Browse files
clydinalan-agius4
authored andcommitted
test(@angular/build): robustly install @angular/animations in e2e test
Enhance the animations package installation in the E2E test to support snapshot E2E runs by resolving the exact dependency specifier from the ng-snapshot manifest when --ng-snapshots is active. Otherwise, it reads the full installed version of @angular/core directly from the local node_modules to avoid semver issues during package installation.
1 parent 73233dc commit 7a0638f

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

tests/e2e/tests/build/chunk-optimizer-animations.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
import assert from 'node:assert/strict';
22
import { readdir } from 'node:fs/promises';
3+
import { getGlobalVariable } from '../../utils/env';
34
import { readFile, writeFile } from '../../utils/fs';
45
import { installPackage } from '../../utils/packages';
56
import { execWithEnv } from '../../utils/process';
7+
import { readNgVersion } from '../../utils/version';
68

79
export default async function () {
8-
// Read @angular/core version from test project's package.json
9-
const projectJson = JSON.parse(await readFile('package.json'));
10-
const ngCoreVersion =
11-
projectJson.dependencies?.['@angular/core'] ??
12-
projectJson.devDependencies?.['@angular/core'] ??
13-
'latest';
10+
const isSnapshotBuild = getGlobalVariable('argv')['ng-snapshots'];
11+
let animationsSpecifier: string;
12+
if (isSnapshotBuild) {
13+
const snapshots = require('../../ng-snapshot/package.json');
14+
animationsSpecifier = snapshots.dependencies['@angular/animations'];
15+
} else {
16+
const coreVersion = readNgVersion();
17+
animationsSpecifier = `@angular/animations@${coreVersion}`;
18+
}
1419

15-
// Install @angular/animations package with matching version
16-
await installPackage(`@angular/animations@${ngCoreVersion}`);
20+
// Install @angular/animations package
21+
await installPackage(animationsSpecifier);
1722

1823
// Configure app.config.ts with provideAnimationsAsync
1924
const originalConfig = await readFile('src/app/app.config.ts');

0 commit comments

Comments
 (0)