@@ -18,18 +18,11 @@ import {
1818 configure as dtlConfigure ,
1919} from '@testing-library/dom' ;
2020import { RenderComponentOptions , RenderDirectiveOptions , RenderResult } from './models' ;
21+ import { getConfig } from './config' ;
2122import { createSelectOptions , createType , tab } from './user-events' ;
2223
2324const mountedFixtures = new Set < ComponentFixture < any > > ( ) ;
2425
25- dtlConfigure ( {
26- eventWrapper : ( cb ) => {
27- const result = cb ( ) ;
28- detectChangesForMountedFixtures ( ) ;
29- return result ;
30- } ,
31- } ) ;
32-
3326export async function render < ComponentType > (
3427 component : Type < ComponentType > ,
3528 renderOptions ?: RenderComponentOptions < ComponentType > ,
@@ -59,9 +52,20 @@ export async function render<SutType, WrapperType = SutType>(
5952 removeAngularAttributes = false ,
6053 } = renderOptions as RenderDirectiveOptions < SutType , WrapperType > ;
6154
55+ const config = getConfig ( ) ;
56+
57+ dtlConfigure ( {
58+ eventWrapper : ( cb ) => {
59+ const result = cb ( ) ;
60+ detectChangesForMountedFixtures ( ) ;
61+ return result ;
62+ } ,
63+ ...config . dom ,
64+ } ) ;
65+
6266 TestBed . configureTestingModule ( {
6367 declarations : addAutoDeclarations ( sut , { declarations, excludeComponentDeclaration, template, wrapper } ) ,
64- imports : addAutoImports ( { imports, routes } ) ,
68+ imports : addAutoImports ( { imports : imports . concat ( config . defaultImports ) , routes } ) ,
6569 providers : [ ...providers ] ,
6670 schemas : [ ...schemas ] ,
6771 } ) ;
@@ -102,7 +106,7 @@ export async function render<SutType, WrapperType = SutType>(
102106 // Call ngOnChanges on initial render
103107 if ( hasOnChangesHook ( fixture . componentInstance ) ) {
104108 const changes = getChangesObj ( null , fixture . componentInstance ) ;
105- fixture . componentInstance . ngOnChanges ( changes )
109+ fixture . componentInstance . ngOnChanges ( changes ) ;
106110 }
107111
108112 if ( detectChangesOnRender ) {
@@ -224,20 +228,21 @@ function setComponentProperties<SutType>(
224228}
225229
226230function hasOnChangesHook < SutType > ( componentInstance : SutType ) : componentInstance is SutType & OnChanges {
227- return 'ngOnChanges' in componentInstance
228- && typeof ( componentInstance as SutType & OnChanges ) . ngOnChanges === 'function' ;
229- } ;
231+ return (
232+ 'ngOnChanges' in componentInstance && typeof ( componentInstance as SutType & OnChanges ) . ngOnChanges === 'function'
233+ ) ;
234+ }
230235
231- function getChangesObj < SutType > (
232- oldProps : Partial < SutType > | null ,
233- newProps : Partial < SutType >
234- ) {
236+ function getChangesObj < SutType > ( oldProps : Partial < SutType > | null , newProps : Partial < SutType > ) {
235237 const isFirstChange = oldProps === null ;
236- return Object . keys ( newProps ) . reduce < SimpleChanges > ( ( changes , key ) => ( {
237- ...changes ,
238- [ key ] : new SimpleChange ( isFirstChange ? null : oldProps [ key ] , newProps [ key ] , isFirstChange )
239- } ) , { } ) ;
240- } ;
238+ return Object . keys ( newProps ) . reduce < SimpleChanges > (
239+ ( changes , key ) => ( {
240+ ...changes ,
241+ [ key ] : new SimpleChange ( isFirstChange ? null : oldProps [ key ] , newProps [ key ] , isFirstChange ) ,
242+ } ) ,
243+ { } ,
244+ ) ;
245+ }
241246
242247function addAutoDeclarations < SutType > (
243248 component : Type < SutType > ,
@@ -425,7 +430,6 @@ const userEvent = {
425430 */
426431export {
427432 buildQueries ,
428- configure ,
429433 getByLabelText ,
430434 getAllByLabelText ,
431435 queryByLabelText ,
0 commit comments