diff --git a/projects/testing-library/src/lib/testing-library.ts b/projects/testing-library/src/lib/testing-library.ts index c4b8d86..933e982 100644 --- a/projects/testing-library/src/lib/testing-library.ts +++ b/projects/testing-library/src/lib/testing-library.ts @@ -122,7 +122,11 @@ export async function render( const router = inject(Router); if (typeof router?.initialNavigation === 'function') { - router?.initialNavigation(); + if (zone) { + zone.run(() => router?.initialNavigation()); + } else { + router?.initialNavigation(); + } } const navigate = async (elementOrPath: Element | string, basePath = ''): Promise => { @@ -130,23 +134,23 @@ export async function render( const [path, params] = (basePath + href).split('?'); const queryParams = params ? params.split('&').reduce((qp, q) => { - const [key, value] = q.split('='); - const currentValue = qp[key]; - if (typeof currentValue === 'undefined') { - qp[key] = value; - } else if (Array.isArray(currentValue)) { - qp[key] = [...currentValue, value]; - } else { - qp[key] = [currentValue, value]; - } - return qp; - }, {} as Record) + const [key, value] = q.split('='); + const currentValue = qp[key]; + if (typeof currentValue === 'undefined') { + qp[key] = value; + } else if (Array.isArray(currentValue)) { + qp[key] = [...currentValue, value]; + } else { + qp[key] = [currentValue, value]; + } + return qp; + }, {} as Record) : undefined; const navigateOptions: NavigationExtras | undefined = queryParams ? { - queryParams, - } + queryParams, + } : undefined; const doNavigate = () => { @@ -411,7 +415,7 @@ if (typeof process === 'undefined' || !process.env?.ATL_SKIP_AUTO_CLEANUP) { } @Component({ selector: 'atl-wrapper-component', template: '' }) -class WrapperComponent { } +class WrapperComponent {} /** * Wrap findBy queries to poke the Angular change detection cycle