Skip to content

Commit d51e63b

Browse files
clydindgp1130
authored andcommittedMay 10, 2022
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 e72fbcd commit d51e63b

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
 
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
* @fileoverview
9+
* Tests the minimal conversion of a newly generated application
10+
* to use a single standalone component.
11+
*/
12+
13+
import { writeFile } from '../../utils/fs';
14+
import { ng } from '../../utils/process';
15+
16+
/**
17+
* An application main file that uses a standalone component with
18+
* bootstrapApplication to start the application. `ng-template` and
19+
* `ngIf` are used to ensure that `CommonModule` and `imports` are
20+
* working in standalone mode.
21+
*/
22+
const STANDALONE_MAIN_CONTENT = `
23+
import { Component } from '@angular/core';
24+
import { CommonModule } from '@angular/common';
25+
import { bootstrapApplication } from '@angular/platform-browser';
26+
27+
@Component({
28+
selector: 'app-root',
29+
standalone: true,
30+
template: \`
31+
<ng-template [ngIf]="isVisible">
32+
<div class="content">
33+
<span>{{name}} app is running!</span>
34+
</div>
35+
</ng-template>
36+
\`,
37+
imports: [CommonModule],
38+
})
39+
export class AppComponent {
40+
name = 'test-project';
41+
isVisible = true;
42+
}
43+
44+
bootstrapApplication(AppComponent);
45+
`;
46+
47+
export default async function () {
48+
// Update to a standalone application
49+
await writeFile('src/main.ts', STANDALONE_MAIN_CONTENT);
50+
51+
// Execute a production build
52+
await ng('build');
53+
54+
// Perform the default E2E tests
55+
await ng('e2e', 'test-project');
56+
}

0 commit comments

Comments
 (0)
Please sign in to comment.