@@ -46,6 +46,7 @@ import {ApplicationRef} from '../src/application/application_ref';
4646import { NoopNgZone } from '../src/zone/ng_zone' ;
4747import { ComponentFixtureNoNgZone , inject , TestBed , waitForAsync , withModule } from '../testing' ;
4848import { take } from 'rxjs/operators' ;
49+ import { compileNgModuleFactory } from '../src/application/application_ngmodule_factory_compiler' ;
4950
5051let serverPlatformModule : Promise < Type < ServerModule > > | null = null ;
5152if ( isNode ) {
@@ -659,45 +660,38 @@ describe('bootstrap', () => {
659660 initializerDone = true ;
660661 } , 1 ) ;
661662
662- const compilerFactory : CompilerFactory = defaultPlatform . injector . get ( CompilerFactory , null ) ! ;
663- const moduleFactory = compilerFactory
664- . createCompiler ( )
665- . compileModuleSync (
666- await createModule ( [ { provide : APP_INITIALIZER , useValue : ( ) => promise , multi : true } ] ) ,
667- ) ;
663+ const moduleType = await createModule ( [
664+ { provide : APP_INITIALIZER , useValue : ( ) => promise , multi : true } ,
665+ ] ) ;
666+ const moduleFactory = await compileNgModuleFactory ( defaultPlatform . injector , { } , moduleType ) ;
667+
668668 defaultPlatform . bootstrapModuleFactory ( moduleFactory ) . then ( ( _ ) => {
669669 expect ( initializerDone ) . toBe ( true ) ;
670670 } ) ;
671671 } ) ) ;
672672
673673 it ( 'should rethrow sync errors even if the exceptionHandler is not rethrowing' , waitForAsync ( async ( ) => {
674- const compilerFactory : CompilerFactory = defaultPlatform . injector . get ( CompilerFactory , null ) ! ;
675- const moduleFactory = compilerFactory . createCompiler ( ) . compileModuleSync (
676- await createModule ( [
677- {
678- provide : APP_INITIALIZER ,
679- useValue : ( ) => {
680- throw 'Test' ;
681- } ,
682- multi : true ,
674+ const moduleType = await createModule ( [
675+ {
676+ provide : APP_INITIALIZER ,
677+ useValue : ( ) => {
678+ throw 'Test' ;
683679 } ,
684- ] ) ,
685- ) ;
680+ multi : true ,
681+ } ,
682+ ] ) ;
683+ const moduleFactory = await compileNgModuleFactory ( defaultPlatform . injector , { } , moduleType ) ;
686684 expect ( ( ) => defaultPlatform . bootstrapModuleFactory ( moduleFactory ) ) . toThrow ( 'Test' ) ;
687685 // Error rethrown will be seen by the exception handler since it's after
688686 // construction.
689687 expect ( mockConsole . res [ 0 ] . join ( '#' ) ) . toEqual ( 'ERROR#Test' ) ;
690688 } ) ) ;
691689
692690 it ( 'should rethrow promise errors even if the exceptionHandler is not rethrowing' , waitForAsync ( async ( ) => {
693- const compilerFactory : CompilerFactory = defaultPlatform . injector . get ( CompilerFactory , null ) ! ;
694- const moduleFactory = compilerFactory
695- . createCompiler ( )
696- . compileModuleSync (
697- await createModule ( [
698- { provide : APP_INITIALIZER , useValue : ( ) => Promise . reject ( 'Test' ) , multi : true } ,
699- ] ) ,
700- ) ;
691+ const moduleType = await createModule ( [
692+ { provide : APP_INITIALIZER , useValue : ( ) => Promise . reject ( 'Test' ) , multi : true } ,
693+ ] ) ;
694+ const moduleFactory = await compileNgModuleFactory ( defaultPlatform . injector , { } , moduleType ) ;
701695 defaultPlatform . bootstrapModuleFactory ( moduleFactory ) . then (
702696 ( ) => expect ( false ) . toBe ( true ) ,
703697 ( e ) => {
0 commit comments