Skip to content

Commit

Permalink
fix: invoke initialNavigation if it's a method
Browse files Browse the repository at this point in the history
In some tests we might mock the router instance, and don't provide the initial navigation
  • Loading branch information
timdeschryver committed Mar 22, 2022
1 parent 8dba35b commit 6e4723b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion projects/testing-library/src/lib/testing-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ export async function render<SutType, WrapperType = SutType>(
const zone = inject(NgZone);

const router = inject(Router);
router?.initialNavigation();
if (typeof router?.initialNavigation === 'function') {
router?.initialNavigation();
}

const navigate = async (elementOrPath: Element | string, basePath = ''): Promise<boolean> => {
const href = typeof elementOrPath === 'string' ? elementOrPath : elementOrPath.getAttribute('href');
Expand Down

0 comments on commit 6e4723b

Please sign in to comment.