@@ -5,11 +5,13 @@ import {
55 silentExecAndWaitForOutputToMatch ,
66 ng ,
77} from '../../utils/process' ;
8- import { writeFile , writeMultipleFiles , appendToFile , expectFileToMatch } from '../../utils/fs' ;
8+ import { writeFile , writeMultipleFiles } from '../../utils/fs' ;
99import { wait } from '../../utils/utils' ;
1010import { request } from '../../utils/http' ;
1111import { getGlobalVariable } from '../../utils/env' ;
1212
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 .../ ;
1315
1416export default function ( ) {
1517 if ( process . platform . startsWith ( 'win' ) ) {
@@ -23,22 +25,19 @@ export default function() {
2325 let oldNumberOfChunks = 0 ;
2426 const chunkRegExp = / c h u n k \s + \{ / g;
2527
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 )
2829 // Should trigger a rebuild.
2930 . 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 ) )
3433 // Count the bundles.
3534 . then ( ( { stdout } ) => {
3635 oldNumberOfChunks = stdout . split ( chunkRegExp ) . length ;
3736 } )
3837 // Add a lazy module.
3938 . then ( ( ) => ng ( 'generate' , 'module' , 'lazy' , '--routing' ) )
4039 // Just wait for the rebuild, otherwise we might be validating the last build.
41- . then ( ( ) => wait ( 2000 ) )
40+ . then ( ( ) => waitForAnyProcessOutputToMatch ( validBundleRegEx , 10000 ) )
4241 . then ( ( ) => writeFile ( 'src/app/app.module.ts' , `
4342 import { BrowserModule } from '@angular/platform-browser';
4443 import { NgModule } from '@angular/core';
@@ -65,18 +64,15 @@ export default function() {
6564 })
6665 export class AppModule { }
6766 ` ) )
68- . then ( ( ) => wait ( 2000 ) )
6967 // 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 ) )
7269 // Count the bundles.
7370 . then ( ( { stdout } ) => {
7471 let newNumberOfChunks = stdout . split ( chunkRegExp ) . length ;
7572 if ( oldNumberOfChunks >= newNumberOfChunks ) {
7673 throw new Error ( 'Expected webpack to create a new chunk, but did not.' ) ;
7774 }
7875 } )
79- . then ( ( ) => wait ( 2000 ) )
8076 // Change multiple files and check that all of them are invalidated and recompiled.
8177 . then ( ( ) => writeMultipleFiles ( {
8278 'src/app/app.module.ts' : `
@@ -89,8 +85,7 @@ export default function() {
8985 console.log('$$_E2E_GOLDEN_VALUE_3');
9086 `
9187 } ) )
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 ) )
9489 . then ( ( ) => wait ( 2000 ) )
9590 . then ( ( ) => request ( 'http://localhost:4200/main.bundle.js' ) )
9691 . then ( ( body ) => {
0 commit comments