@@ -11,6 +11,7 @@ import {
1111 SimpleChanges ,
1212 Type ,
1313 isStandalone ,
14+ provideZonelessChangeDetection ,
1415} from '@angular/core' ;
1516import { ComponentFixture , DeferBlockBehavior , DeferBlockState , TestBed , tick } from '@angular/core/testing' ;
1617import { NavigationExtras , Router } from '@angular/router' ;
@@ -79,6 +80,7 @@ export async function render<SutType, WrapperType = SutType>(
7980 initialRoute = '' ,
8081 deferBlockStates = undefined ,
8182 deferBlockBehavior = undefined ,
83+ zoneless = false ,
8284 configureTestBed = ( ) => {
8385 /* noop*/
8486 } ,
@@ -107,7 +109,10 @@ export async function render<SutType, WrapperType = SutType>(
107109 imports : imports . concat ( defaultImports ) ,
108110 routes,
109111 } ) ,
110- providers,
112+ providers : addAutoProviders ( {
113+ providers : [ ...providers ] ,
114+ zoneless,
115+ } ) ,
111116 schemas : [ ...schemas ] ,
112117 deferBlockBehavior : deferBlockBehavior ?? DeferBlockBehavior . Manual ,
113118 } ) ;
@@ -518,6 +523,14 @@ function addAutoImports<SutType>(
518523 return [ ...imports , ...components ( ) , ...routing ( ) ] ;
519524}
520525
526+ function addAutoProviders ( {
527+ providers = [ ] ,
528+ zoneless,
529+ } : Pick < RenderTemplateOptions < any > , 'providers' > & Pick < Config , 'zoneless' > ) {
530+ const provideZoneless = ( ) => ( zoneless ? [ provideZonelessChangeDetection ( ) ] : [ ] ) ;
531+ return [ ...providers , ...provideZoneless ( ) ] ;
532+ }
533+
521534async function renderDeferBlock < SutType > (
522535 fixture : ComponentFixture < SutType > ,
523536 deferBlockState : DeferBlockState ,
0 commit comments