From: Eduardo San Martin Morote Date: Tue, 1 Jun 2021 21:33:08 +0000 (+0200) Subject: test(errors): test onError for lazy import X-Git-Tag: v4.0.9~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9dc994abf257846b3d1cceda8aa73a435b460b09;p=thirdparty%2Fvuejs%2Frouter.git test(errors): test onError for lazy import --- diff --git a/__tests__/errors.spec.ts b/__tests__/errors.spec.ts index ba85b09a..8dd323f7 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()