Replace router push with the one that catches errors

This commit is contained in:
Angelina Filippova 2021-02-08 01:42:31 +03:00
parent 5ca76701c2
commit 6722a9e34a
2 changed files with 14 additions and 0 deletions

View File

@ -3,6 +3,19 @@ import Router from 'vue-router'
Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) { return originalPush.call(this, location, onResolve, onReject) }
return originalPush.call(this, location).catch((err) => {
if (Router.isNavigationFailure(err)) {
// resolve err
return err
}
// rethrow error
return Promise.reject(err)
})
}
/* Layout */
import Layout from '@/views/layout/Layout'

View File

@ -16,6 +16,7 @@ localVue.use(VueRouter)
localVue.use(Element)
jest.mock('@/api/reports')
jest.mock('@/api/settings')
describe('Log out', () => {
let store