Skip to content

Commit 9141c84

Browse files
committed
test: add a minimal standalone component application E2E test
A new E2E test has been added that updates a newly generated application to use a standalone component that is bootstrapped with the newly introduced `bootstrapApplication` API. This test is intended to check that the minimal functionality for a standalone-based application functions with the Angular CLI. More expansive tests will be added as standalone features and capabilities are introduced within the Angular CLI.
1 parent 8bdf1a8 commit 9141c84

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
/**
10+
* @fileoverview Tests the minimal conversion of a newly generated application
11+
* to use a single standalone component.
12+
*/
13+
14+
import { writeFile } from '../../utils/fs';
15+
import { ng } from '../../utils/process';
16+
17+
/**
18+
* An application main file that uses a standalone component with
19+
* bootstrapApplication to start the application.
20+
*/
21+
const STANDALONE_MAIN_CONTENT = `
22+
import { Component } from '@angular/core';
23+
import { CommonModule } from '@angular/common';
24+
import { bootstrapApplication } from '@angular/platform-browser';
25+
26+
@Component({
27+
selector: 'app-root',
28+
standalone: true,
29+
template: \`
30+
<ng-template [ngIf]="isVisible">
31+
<div class="content">
32+
<span>{{name}} app is running!</span>
33+
</div>
34+
</ng-template>
35+
\`,
36+
imports: [CommonModule],
37+
})
38+
export class AppComponent {
39+
name = 'test-project';
40+
isVisible = true;
41+
}
42+
43+
bootstrapApplication(AppComponent);
44+
`;
45+
46+
export default async function () {
47+
// Update to a standalone application
48+
await writeFile('src/main.ts', STANDALONE_MAIN_CONTENT);
49+
50+
// Execute a production build
51+
await ng('build');
52+
53+
// Perform the default E2E tests
54+
await ng('e2e', 'test-project');
55+
}

0 commit comments

Comments
 (0)