77 */
88// tslint:disable:no-big-function
99import { Architect } from '@angular-devkit/architect' ;
10- import { TestLogger } from '@angular-devkit/architect/testing' ;
11- import { join , normalize , virtualFs } from '@angular-devkit/core' ;
10+ import { join , logging , normalize , virtualFs } from '@angular-devkit/core' ;
1211import { debounceTime , take , takeWhile , tap } from 'rxjs/operators' ;
1312import {
1413 createArchitect ,
@@ -154,7 +153,10 @@ describe('Browser Builder rebuilds', () => {
154153 ) ;
155154
156155 const overrides = { watch : true , forkTypeChecker : false } ;
157- const logger = new TestLogger ( 'rebuild-type-errors' ) ;
156+ const logger = new logging . Logger ( '' ) ;
157+ let logs : string [ ] = [ ] ;
158+ logger . subscribe ( e => logs . push ( e . message ) ) ;
159+
158160 const typeError = `is not assignable to parameter of type 'number'` ;
159161 let buildNumber = 0 ;
160162
@@ -177,8 +179,8 @@ describe('Browser Builder rebuilds', () => {
177179 case 2 :
178180 // The second build should error out with a type error on the type of an argument.
179181 expect ( buildEvent . success ) . toBe ( false ) ;
180- expect ( logger . includes ( typeError ) ) . toBe ( true ) ;
181- logger . clear ( ) ;
182+ expect ( logs . join ( ) . includes ( typeError ) ) . toBe ( true ) ;
183+ logs = [ ] ;
182184 // Change an UNRELATED file and the error should still happen.
183185 // Should trigger a rebuild, this time an error is also expected.
184186 host . appendToFile ( 'src/app/app.module.ts' , `console.log(1);` ) ;
@@ -187,8 +189,8 @@ describe('Browser Builder rebuilds', () => {
187189 case 3 :
188190 // The third build should have the same error as the first.
189191 expect ( buildEvent . success ) . toBe ( false ) ;
190- expect ( logger . includes ( typeError ) ) . toBe ( true ) ;
191- logger . clear ( ) ;
192+ expect ( logs . join ( ) . includes ( typeError ) ) . toBe ( true ) ;
193+ logs = [ ] ;
192194 // Fix the error.
193195 host . writeMultipleFiles ( {
194196 'src/funky2.ts' : `export const funky2 = (value: string) => value + 'hello';` ,
@@ -350,7 +352,9 @@ describe('Browser Builder rebuilds', () => {
350352 // show up in getNgSemanticDiagnostics. Since getNgSemanticDiagnostics is only called on the
351353 // type checker, we must disable it to get a failing fourth build with Ivy.
352354 const overrides = { watch : true , aot : true , forkTypeChecker : veEnabled } ;
353- const logger = new TestLogger ( 'rebuild-aot-errors' ) ;
355+ const logger = new logging . Logger ( '' ) ;
356+ let logs : string [ ] = [ ] ;
357+ logger . subscribe ( e => logs . push ( e . message ) ) ;
354358 const staticAnalysisError = ! veEnabled
355359 ? 'selector must be a string'
356360 : 'Function expressions are not supported in decorators' ;
@@ -367,30 +371,30 @@ describe('Browser Builder rebuilds', () => {
367371 case 1 :
368372 // The first build should error out with a static analysis error.
369373 expect ( buildEvent . success ) . toBe ( false , 'First build should not succeed.' ) ;
370- expect ( logger . includes ( staticAnalysisError ) ) . toBe ( true ,
374+ expect ( logs . join ( ) . includes ( staticAnalysisError ) ) . toBe ( true ,
371375 'First build should have static analysis error.' ) ;
372- logger . clear ( ) ;
376+ logs = [ ] ;
373377 // Fix the static analysis error.
374378 host . writeMultipleFiles ( { 'src/app/app.component.ts' : origContent } ) ;
375379 break ;
376380
377381 case 2 :
378382 expect ( buildEvent . success ) . toBe ( true , 'Second build should succeed.' ) ;
379- expect ( logger . includes ( staticAnalysisError ) ) . toBe ( false ,
383+ expect ( logs . join ( ) . includes ( staticAnalysisError ) ) . toBe ( false ,
380384 'Second build should not have static analysis error.' ) ;
381- logger . clear ( ) ;
385+ logs = [ ] ;
382386 // Add an syntax error to a non-main file.
383387 host . appendToFile ( 'src/app/app.component.ts' , `]]]` ) ;
384388 break ;
385389
386390 case 3 :
387391 // The third build should have TS syntax error.
388392 expect ( buildEvent . success ) . toBe ( false , 'Third build should not succeed.' ) ;
389- expect ( logger . includes ( syntaxError ) ) . toBe ( true ,
393+ expect ( logs . join ( ) . includes ( syntaxError ) ) . toBe ( true ,
390394 'Third build should have syntax analysis error.' ) ;
391- expect ( logger . includes ( staticAnalysisError ) ) . toBe ( false ,
395+ expect ( logs . join ( ) . includes ( staticAnalysisError ) ) . toBe ( false ,
392396 'Third build should not have static analysis error.' ) ;
393- logger . clear ( ) ;
397+ logs = [ ] ;
394398 // Fix the syntax error, but add the static analysis error again.
395399 host . writeMultipleFiles ( {
396400 'src/app/app.component.ts' : origContent . replace (
@@ -402,21 +406,21 @@ describe('Browser Builder rebuilds', () => {
402406
403407 case 4 :
404408 expect ( buildEvent . success ) . toBe ( false , 'Fourth build should not succeed.' ) ;
405- expect ( logger . includes ( syntaxError ) ) . toBe ( false ,
409+ expect ( logs . join ( ) . includes ( syntaxError ) ) . toBe ( false ,
406410 'Fourth build should not have syntax analysis error.' ) ;
407- expect ( logger . includes ( staticAnalysisError ) ) . toBe ( true ,
411+ expect ( logs . join ( ) . includes ( staticAnalysisError ) ) . toBe ( true ,
408412 'Fourth build should have static analysis error.' ) ;
409- logger . clear ( ) ;
413+ logs = [ ] ;
410414 // Restore the file to a error-less state.
411415 host . writeMultipleFiles ( { 'src/app/app.component.ts' : origContent } ) ;
412416 break ;
413417
414418 case 5 :
415419 // The fifth build should have everything fixed..
416420 expect ( buildEvent . success ) . toBe ( true , 'Fifth build should succeed.' ) ;
417- expect ( logger . includes ( syntaxError ) ) . toBe ( false ,
421+ expect ( logs . join ( ) . includes ( syntaxError ) ) . toBe ( false ,
418422 'Fifth build should not have syntax analysis error.' ) ;
419- expect ( logger . includes ( staticAnalysisError ) ) . toBe ( false ,
423+ expect ( logs . join ( ) . includes ( staticAnalysisError ) ) . toBe ( false ,
420424 'Fifth build should not have static analysis error.' ) ;
421425 break ;
422426 }
0 commit comments