@@ -4,22 +4,26 @@ import {
4
4
execAndWaitForOutputToMatch ,
5
5
ng ,
6
6
} from '../../utils/process' ;
7
- import { writeFile , writeMultipleFiles } from '../../utils/fs' ;
8
- import { wait } from '../../utils/utils' ;
9
- import { request } from '../../utils/http' ;
7
+ import { writeFile , writeMultipleFiles } from '../../utils/fs' ;
8
+ import { wait } from '../../utils/utils' ;
9
+ import { request } from '../../utils/http' ;
10
10
11
11
const validBundleRegEx = / C o m p i l e d s u c c e s s f u l l y ./ ;
12
12
13
- export default function ( ) {
14
- return execAndWaitForOutputToMatch ( 'ng' , [ 'serve' ] , validBundleRegEx )
15
- // Add a lazy module.
16
- . then ( ( ) => ng ( 'generate' , 'module' , 'lazy' , '--routing' ) )
17
- // Should trigger a rebuild with a new bundle.
18
- // We need to use Promise.all to ensure we are waiting for the rebuild just before we write
19
- // the file, otherwise rebuilds can be too fast and fail CI.
20
- . then ( ( ) => Promise . all ( [
21
- waitForAnyProcessOutputToMatch ( validBundleRegEx , 20000 ) ,
22
- writeFile ( 'src/app/app.module.ts' , `
13
+ export default function ( ) {
14
+ return (
15
+ execAndWaitForOutputToMatch ( 'ng' , [ 'serve' ] , validBundleRegEx )
16
+ // Add a lazy module.
17
+ . then ( ( ) => ng ( 'generate' , 'module' , 'lazy' , '--routing' ) )
18
+ // Should trigger a rebuild with a new bundle.
19
+ // We need to use Promise.all to ensure we are waiting for the rebuild just before we write
20
+ // the file, otherwise rebuilds can be too fast and fail CI.
21
+ . then ( ( ) =>
22
+ Promise . all ( [
23
+ waitForAnyProcessOutputToMatch ( validBundleRegEx , 20000 ) ,
24
+ writeFile (
25
+ 'src/app/app.module.ts' ,
26
+ `
23
27
import { BrowserModule } from '@angular/platform-browser';
24
28
import { NgModule } from '@angular/core';
25
29
import { FormsModule } from '@angular/forms';
@@ -44,21 +48,23 @@ export default function() {
44
48
bootstrap: [AppComponent]
45
49
})
46
50
export class AppModule { }
47
- ` ) ,
48
- ] ) )
49
- // Count the bundles.
50
- . then ( ( results ) => {
51
- const stdout = results [ 0 ] . stdout ;
52
- // First regexp is for Webpack 4; Second is for Webpack 5
53
- if ( ! / ( l a z y - m o d u l e | 0 ) \. j s / g. test ( stdout ) && ! / l a z y _ m o d u l e _ t s \. j s / g. test ( stdout ) ) {
54
- throw new Error ( 'Expected webpack to create a new chunk, but did not.' ) ;
55
- }
56
- } )
57
- // Change multiple files and check that all of them are invalidated and recompiled.
58
- . then ( ( ) => Promise . all ( [
59
- waitForAnyProcessOutputToMatch ( validBundleRegEx , 20000 ) ,
60
- writeMultipleFiles ( {
61
- 'src/app/app.module.ts' : `
51
+ ` ,
52
+ ) ,
53
+ ] ) ,
54
+ )
55
+ // Count the bundles.
56
+ . then ( ( results ) => {
57
+ const stdout = results [ 0 ] . stdout ;
58
+ if ( ! / l a z y _ m o d u l e _ t s \. j s / g. test ( stdout ) ) {
59
+ throw new Error ( 'Expected webpack to create a new chunk, but did not.' ) ;
60
+ }
61
+ } )
62
+ // Change multiple files and check that all of them are invalidated and recompiled.
63
+ . then ( ( ) =>
64
+ Promise . all ( [
65
+ waitForAnyProcessOutputToMatch ( validBundleRegEx , 20000 ) ,
66
+ writeMultipleFiles ( {
67
+ 'src/app/app.module.ts' : `
62
68
import { BrowserModule } from '@angular/platform-browser';
63
69
import { NgModule } from '@angular/core';
64
70
@@ -79,7 +85,7 @@ export default function() {
79
85
console.log('$$_E2E_GOLDEN_VALUE_1');
80
86
export let X = '$$_E2E_GOLDEN_VALUE_2';
81
87
` ,
82
- 'src/main.ts' : `
88
+ 'src/main.ts' : `
83
89
import { enableProdMode } from '@angular/core';
84
90
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
85
91
@@ -96,12 +102,14 @@ export default function() {
96
102
console.log(m.X);
97
103
console.log('$$_E2E_GOLDEN_VALUE_3');
98
104
` ,
99
- } ) ,
100
- ] ) )
101
- . then ( ( ) => Promise . all ( [
102
- waitForAnyProcessOutputToMatch ( validBundleRegEx , 20000 ) ,
103
- writeMultipleFiles ( {
104
- 'src/app/app.module.ts' : `
105
+ } ) ,
106
+ ] ) ,
107
+ )
108
+ . then ( ( ) =>
109
+ Promise . all ( [
110
+ waitForAnyProcessOutputToMatch ( validBundleRegEx , 20000 ) ,
111
+ writeMultipleFiles ( {
112
+ 'src/app/app.module.ts' : `
105
113
106
114
import { BrowserModule } from '@angular/platform-browser';
107
115
import { NgModule } from '@angular/core';
@@ -124,49 +132,58 @@ export default function() {
124
132
export let X = '$$_E2E_GOLDEN_VALUE_2';
125
133
console.log('File changed with no import/export changes');
126
134
` ,
127
- } ) ,
128
- ] ) )
129
- . then ( ( ) => wait ( 2000 ) )
130
- . then ( ( ) => request ( 'http://localhost:4200/main.js' ) )
131
- . then ( ( body ) => {
132
- if ( ! body . match ( / \$ \$ _ E 2 E _ G O L D E N _ V A L U E _ 1 / ) ) {
133
- throw new Error ( 'Expected golden value 1.' ) ;
134
- }
135
- if ( ! body . match ( / \$ \$ _ E 2 E _ G O L D E N _ V A L U E _ 2 / ) ) {
136
- throw new Error ( 'Expected golden value 2.' ) ;
137
- }
138
- if ( ! body . match ( / \$ \$ _ E 2 E _ G O L D E N _ V A L U E _ 3 / ) ) {
139
- throw new Error ( 'Expected golden value 3.' ) ;
140
- }
141
- } )
142
- . then ( ( ) => Promise . all ( [
143
- waitForAnyProcessOutputToMatch ( validBundleRegEx , 20000 ) ,
144
- writeMultipleFiles ( {
145
- 'src/app/app.component.html' : '<h1>testingTESTING123</h1>' ,
146
- } ) ,
147
- ] ) )
148
- . then ( ( ) => wait ( 2000 ) )
149
- . then ( ( ) => request ( 'http://localhost:4200/main.js' ) )
150
- . then ( ( body ) => {
151
- if ( ! body . match ( / t e s t i n g T E S T I N G 1 2 3 / ) ) {
152
- throw new Error ( 'Expected component HTML to update.' ) ;
153
- }
154
- } )
155
- . then ( ( ) => Promise . all ( [
156
- waitForAnyProcessOutputToMatch ( validBundleRegEx , 20000 ) ,
157
- writeMultipleFiles ( {
158
- 'src/app/app.component.css' : ':host { color: blue; }' ,
159
- } ) ,
160
- ] ) )
161
- . then ( ( ) => wait ( 2000 ) )
162
- . then ( ( ) => request ( 'http://localhost:4200/main.js' ) )
163
- . then ( ( body ) => {
164
- if ( ! body . match ( / c o l o r : \s ? b l u e / ) ) {
165
- throw new Error ( 'Expected component CSS to update.' ) ;
166
- }
167
- } )
168
- . then ( ( ) => killAllProcesses ( ) , ( err : unknown ) => {
169
- killAllProcesses ( ) ;
170
- throw err ;
171
- } ) ;
135
+ } ) ,
136
+ ] ) ,
137
+ )
138
+ . then ( ( ) => wait ( 2000 ) )
139
+ . then ( ( ) => request ( 'http://localhost:4200/main.js' ) )
140
+ . then ( ( body ) => {
141
+ if ( ! body . match ( / \$ \$ _ E 2 E _ G O L D E N _ V A L U E _ 1 / ) ) {
142
+ throw new Error ( 'Expected golden value 1.' ) ;
143
+ }
144
+ if ( ! body . match ( / \$ \$ _ E 2 E _ G O L D E N _ V A L U E _ 2 / ) ) {
145
+ throw new Error ( 'Expected golden value 2.' ) ;
146
+ }
147
+ if ( ! body . match ( / \$ \$ _ E 2 E _ G O L D E N _ V A L U E _ 3 / ) ) {
148
+ throw new Error ( 'Expected golden value 3.' ) ;
149
+ }
150
+ } )
151
+ . then ( ( ) =>
152
+ Promise . all ( [
153
+ waitForAnyProcessOutputToMatch ( validBundleRegEx , 20000 ) ,
154
+ writeMultipleFiles ( {
155
+ 'src/app/app.component.html' : '<h1>testingTESTING123</h1>' ,
156
+ } ) ,
157
+ ] ) ,
158
+ )
159
+ . then ( ( ) => wait ( 2000 ) )
160
+ . then ( ( ) => request ( 'http://localhost:4200/main.js' ) )
161
+ . then ( ( body ) => {
162
+ if ( ! body . match ( / t e s t i n g T E S T I N G 1 2 3 / ) ) {
163
+ throw new Error ( 'Expected component HTML to update.' ) ;
164
+ }
165
+ } )
166
+ . then ( ( ) =>
167
+ Promise . all ( [
168
+ waitForAnyProcessOutputToMatch ( validBundleRegEx , 20000 ) ,
169
+ writeMultipleFiles ( {
170
+ 'src/app/app.component.css' : ':host { color: blue; }' ,
171
+ } ) ,
172
+ ] ) ,
173
+ )
174
+ . then ( ( ) => wait ( 2000 ) )
175
+ . then ( ( ) => request ( 'http://localhost:4200/main.js' ) )
176
+ . then ( ( body ) => {
177
+ if ( ! body . match ( / c o l o r : \s ? b l u e / ) ) {
178
+ throw new Error ( 'Expected component CSS to update.' ) ;
179
+ }
180
+ } )
181
+ . then (
182
+ ( ) => killAllProcesses ( ) ,
183
+ ( err : unknown ) => {
184
+ killAllProcesses ( ) ;
185
+ throw err ;
186
+ } ,
187
+ )
188
+ ) ;
172
189
}
0 commit comments