Skip to content

Commit 6e4723b

Browse files
committed
fix: invoke initialNavigation if it's a method
In some tests we might mock the router instance, and don't provide the initial navigation
1 parent 8dba35b commit 6e4723b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ export async function render<SutType, WrapperType = SutType>(
119119
const zone = inject(NgZone);
120120

121121
const router = inject(Router);
122-
router?.initialNavigation();
122+
if (typeof router?.initialNavigation === 'function') {
123+
router?.initialNavigation();
124+
}
123125

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

0 commit comments

Comments
 (0)