]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test(errors): test onError for lazy import
authorEduardo San Martin Morote <posva13@gmail.com>
Tue, 1 Jun 2021 21:33:08 +0000 (23:33 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Tue, 1 Jun 2021 21:33:08 +0000 (23:33 +0200)
__tests__/errors.spec.ts

index ba85b09aefb2109e2e14778de5cccf16107abf4a..8dd323f76261a309f16c74f6a985b48dff49a4a3 100644 (file)
@@ -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()