@@ -11,6 +11,7 @@ import {
11
11
SimpleChanges ,
12
12
Type ,
13
13
isStandalone ,
14
+ provideZonelessChangeDetection ,
14
15
} from '@angular/core' ;
15
16
import { ComponentFixture , DeferBlockBehavior , DeferBlockState , TestBed , tick } from '@angular/core/testing' ;
16
17
import { NavigationExtras , Router } from '@angular/router' ;
@@ -79,6 +80,7 @@ export async function render<SutType, WrapperType = SutType>(
79
80
initialRoute = '' ,
80
81
deferBlockStates = undefined ,
81
82
deferBlockBehavior = undefined ,
83
+ zoneless = false ,
82
84
configureTestBed = ( ) => {
83
85
/* noop*/
84
86
} ,
@@ -107,7 +109,10 @@ export async function render<SutType, WrapperType = SutType>(
107
109
imports : imports . concat ( defaultImports ) ,
108
110
routes,
109
111
} ) ,
110
- providers,
112
+ providers : addAutoProviders ( {
113
+ providers : [ ...providers ] ,
114
+ zoneless,
115
+ } ) ,
111
116
schemas : [ ...schemas ] ,
112
117
deferBlockBehavior : deferBlockBehavior ?? DeferBlockBehavior . Manual ,
113
118
} ) ;
@@ -518,6 +523,14 @@ function addAutoImports<SutType>(
518
523
return [ ...imports , ...components ( ) , ...routing ( ) ] ;
519
524
}
520
525
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
+
521
534
async function renderDeferBlock < SutType > (
522
535
fixture : ComponentFixture < SutType > ,
523
536
deferBlockState : DeferBlockState ,
0 commit comments