From 9dc994abf257846b3d1cceda8aa73a435b460b09 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Tue, 1 Jun 2021 23:33:08 +0200 Subject: [PATCH] test(errors): test onError for lazy import --- __tests__/errors.spec.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/__tests__/errors.spec.ts b/__tests__/errors.spec.ts index ba85b09ae..8dd323f76 100644 --- a/__tests__/errors.spec.ts +++ b/__tests__/errors.spec.ts @@ -21,6 +21,7 @@ const routes: RouteRecordRaw[] = [ { path: '/foo', component: components.Foo, name: 'Foo' }, // prevent the log of no match warnings { path: '/:pathMatch(.*)', component: components.Home }, + { path: '/async', component: () => Promise.reject('failed') }, ] const onError = jest.fn() @@ -52,6 +53,10 @@ describe('Errors & Navigation failures', () => { ) }) + it('lazy loading reject', async () => { + await testError(true, 'failed', '/async') + }) + it('Duplicated navigation triggers afterEach', async () => { let expectedFailure = expect.objectContaining({ type: NavigationFailureType.duplicated, @@ -315,7 +320,7 @@ describe('isNavigationFailure', () => { async function testError( nextArgument: any | NavigationGuard, - expectedError: Error | void = undefined, + expectedError: any = undefined, to: RouteLocationRaw = '/foo' ) { const { router } = createRouter()