Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bb2f9eb

Browse files
fix: re-add zoneless for render (#538)
1 parent 72ca608 commit bb2f9eb

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎projects/testing-library/src/lib/testing-library.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
SimpleChanges,
1212
Type,
1313
isStandalone,
14+
provideZonelessChangeDetection,
1415
} from '@angular/core';
1516
import { ComponentFixture, DeferBlockBehavior, DeferBlockState, TestBed, tick } from '@angular/core/testing';
1617
import { 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+
521534
async function renderDeferBlock<SutType>(
522535
fixture: ComponentFixture<SutType>,
523536
deferBlockState: DeferBlockState,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /