@@ -5,11 +5,13 @@ import {
5
5
silentExecAndWaitForOutputToMatch ,
6
6
ng ,
7
7
} from '../../utils/process' ;
8
- import { writeFile , writeMultipleFiles , appendToFile , expectFileToMatch } from '../../utils/fs' ;
8
+ import { writeFile , writeMultipleFiles } from '../../utils/fs' ;
9
9
import { wait } from '../../utils/utils' ;
10
10
import { request } from '../../utils/http' ;
11
11
import { getGlobalVariable } from '../../utils/env' ;
12
12
13
+ const validBundleRegEx = / w e b p a c k : b u n d l e i s n o w V A L I D | w e b p a c k : C o m p i l e d s u c c e s s f u l l y ./ ;
14
+ const invalidBundleRegEx = / w e b p a c k : b u n d l e i s n o w I N V A L I D | w e b p a c k : C o m p i l i n g .../ ;
13
15
14
16
export default function ( ) {
15
17
if ( process . platform . startsWith ( 'win' ) ) {
@@ -23,22 +25,19 @@ export default function() {
23
25
let oldNumberOfChunks = 0 ;
24
26
const chunkRegExp = / c h u n k \s + \{ / g;
25
27
26
- return silentExecAndWaitForOutputToMatch ( 'ng' , [ 'serve' ] ,
27
- / w e b p a c k : b u n d l e i s n o w V A L I D | w e b p a c k : C o m p i l e d s u c c e s s f u l l y ./ )
28
+ return silentExecAndWaitForOutputToMatch ( 'ng' , [ 'serve' ] , validBundleRegEx )
28
29
// Should trigger a rebuild.
29
30
. then ( ( ) => exec ( 'touch' , 'src/main.ts' ) )
30
- . then ( ( ) => waitForAnyProcessOutputToMatch (
31
- / w e b p a c k : b u n d l e i s n o w I N V A L I D | w e b p a c k : C o m p i l i n g .../ , 10000 ) )
32
- . then ( ( ) => waitForAnyProcessOutputToMatch (
33
- / w e b p a c k : b u n d l e i s n o w V A L I D | w e b p a c k : C o m p i l e d s u c c e s s f u l l y ./ , 10000 ) )
31
+ . then ( ( ) => waitForAnyProcessOutputToMatch ( invalidBundleRegEx , 10000 ) )
32
+ . then ( ( ) => waitForAnyProcessOutputToMatch ( validBundleRegEx , 10000 ) )
34
33
// Count the bundles.
35
34
. then ( ( { stdout } ) => {
36
35
oldNumberOfChunks = stdout . split ( chunkRegExp ) . length ;
37
36
} )
38
37
// Add a lazy module.
39
38
. then ( ( ) => ng ( 'generate' , 'module' , 'lazy' , '--routing' ) )
40
39
// Just wait for the rebuild, otherwise we might be validating the last build.
41
- . then ( ( ) => wait ( 2000 ) )
40
+ . then ( ( ) => waitForAnyProcessOutputToMatch ( validBundleRegEx , 10000 ) )
42
41
. then ( ( ) => writeFile ( 'src/app/app.module.ts' , `
43
42
import { BrowserModule } from '@angular/platform-browser';
44
43
import { NgModule } from '@angular/core';
@@ -65,18 +64,15 @@ export default function() {
65
64
})
66
65
export class AppModule { }
67
66
` ) )
68
- . then ( ( ) => wait ( 2000 ) )
69
67
// Should trigger a rebuild with a new bundle.
70
- . then ( ( ) => waitForAnyProcessOutputToMatch (
71
- / w e b p a c k : b u n d l e i s n o w V A L I D | w e b p a c k : C o m p i l e d s u c c e s s f u l l y ./ , 10000 ) )
68
+ . then ( ( ) => waitForAnyProcessOutputToMatch ( validBundleRegEx , 10000 ) )
72
69
// Count the bundles.
73
70
. then ( ( { stdout } ) => {
74
71
let newNumberOfChunks = stdout . split ( chunkRegExp ) . length ;
75
72
if ( oldNumberOfChunks >= newNumberOfChunks ) {
76
73
throw new Error ( 'Expected webpack to create a new chunk, but did not.' ) ;
77
74
}
78
75
} )
79
- . then ( ( ) => wait ( 2000 ) )
80
76
// Change multiple files and check that all of them are invalidated and recompiled.
81
77
. then ( ( ) => writeMultipleFiles ( {
82
78
'src/app/app.module.ts' : `
@@ -89,8 +85,7 @@ export default function() {
89
85
console.log('$$_E2E_GOLDEN_VALUE_3');
90
86
`
91
87
} ) )
92
- . then ( ( ) => waitForAnyProcessOutputToMatch (
93
- / w e b p a c k : b u n d l e i s n o w V A L I D | w e b p a c k : C o m p i l e d s u c c e s s f u l l y ./ , 10000 ) )
88
+ . then ( ( ) => waitForAnyProcessOutputToMatch ( validBundleRegEx , 10000 ) )
94
89
. then ( ( ) => wait ( 2000 ) )
95
90
. then ( ( ) => request ( 'http://localhost:4200/main.bundle.js' ) )
96
91
. then ( ( body ) => {
0 commit comments