6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { DefaultTimeout , runTargetSpec } from '@angular-devkit/architect/testing' ;
9
+ import { DefaultTimeout , TestLogger , runTargetSpec } from '@angular-devkit/architect/testing' ;
10
10
import { join , normalize } from '@angular-devkit/core' ;
11
- import { tap } from 'rxjs/operators' ;
11
+ import { take , tap } from 'rxjs/operators' ;
12
12
import { BrowserBuilderSchema } from '../../src' ;
13
13
import { browserTargetSpec , host } from '../utils' ;
14
14
@@ -70,6 +70,7 @@ export const lazyModuleImport: { [path: string]: string } = {
70
70
` ,
71
71
} ;
72
72
73
+ // tslint:disable-next-line:no-big-function
73
74
describe ( 'Browser Builder lazy modules' , ( ) => {
74
75
75
76
const outputPath = normalize ( 'dist' ) ;
@@ -89,6 +90,28 @@ describe('Browser Builder lazy modules', () => {
89
90
) . toPromise ( ) . then ( done , done . fail ) ;
90
91
} ) ;
91
92
93
+ it ( 'should show error when lazy route is invalid on watch mode AOT' , ( done ) => {
94
+ host . writeMultipleFiles ( lazyModuleFiles ) ;
95
+ host . writeMultipleFiles ( lazyModuleImport ) ;
96
+ host . replaceInFile (
97
+ 'src/app/app.module.ts' ,
98
+ 'lazy.module#LazyModule' ,
99
+ 'invalid.module#LazyModule' ,
100
+ ) ;
101
+
102
+ const logger = new TestLogger ( 'rebuild-lazy-errors' ) ;
103
+ const overrides = { watch : true , aot : true } ;
104
+ runTargetSpec ( host , browserTargetSpec , overrides , DefaultTimeout , logger ) . pipe (
105
+ tap ( ( buildEvent ) => expect ( buildEvent . success ) . toBe ( false ) ) ,
106
+ tap ( ( ) => {
107
+ expect ( logger . includes ( 'Could not resolve module' ) ) . toBe ( true ) ;
108
+ logger . clear ( ) ;
109
+ host . appendToFile ( 'src/main.ts' , ' ' ) ;
110
+ } ) ,
111
+ take ( 2 ) ,
112
+ ) . toPromise ( ) . then ( done , done . fail ) ;
113
+ } ) ;
114
+
92
115
it ( 'supports lazy bundle for lazy routes with AOT' , ( done ) => {
93
116
host . writeMultipleFiles ( lazyModuleFiles ) ;
94
117
host . writeMultipleFiles ( lazyModuleImport ) ;
0 commit comments