|
@ -127,25 +127,25 @@ describe('Error handling', () => { |
|
|
}).then(done) |
|
|
}).then(done) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
it('should recover from errors in user watcher callback', done => { |
|
|
;[ |
|
|
const vm = createTestInstance(components.userWatcherCallback) |
|
|
['userWatcherCallback', 'watcher'], |
|
|
vm.n++ |
|
|
['userImmediateWatcherCallback', 'immediate watcher'] |
|
|
waitForUpdate(() => { |
|
|
].forEach(([type, description]) => { |
|
|
expect(`Error in callback for watcher "n"`).toHaveBeenWarned() |
|
|
it(`should recover from errors in user ${description} callback`, done => { |
|
|
expect(`Error: userWatcherCallback`).toHaveBeenWarned() |
|
|
const vm = createTestInstance(components[type]) |
|
|
}).thenWaitFor(next => { |
|
|
assertBothInstancesActive(vm).then(() => { |
|
|
assertBothInstancesActive(vm).end(next) |
|
|
expect(`Error in callback for ${description} "n"`).toHaveBeenWarned() |
|
|
}).then(done) |
|
|
expect(`Error: ${type} error`).toHaveBeenWarned() |
|
|
}) |
|
|
}).then(done) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
it('should recover from errors in user immediate watcher callback', done => { |
|
|
it(`should recover from promise errors in user ${description} callback`, done => { |
|
|
const vm = createTestInstance(components.userImmediateWatcherCallback) |
|
|
const vm = createTestInstance(components[`${type}Async`]) |
|
|
waitForUpdate(() => { |
|
|
assertBothInstancesActive(vm).then(() => { |
|
|
expect(`Error in callback for immediate watcher "n"`).toHaveBeenWarned() |
|
|
expect(`Error in callback for ${description} "n" (Promise/async)`).toHaveBeenWarned() |
|
|
expect(`Error: userImmediateWatcherCallback error`).toHaveBeenWarned() |
|
|
expect(`Error: ${type} error`).toHaveBeenWarned() |
|
|
}).thenWaitFor(next => { |
|
|
}).then(done) |
|
|
assertBothInstancesActive(vm).end(next) |
|
|
}) |
|
|
}).then(done) |
|
|
|
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
it('config.errorHandler should capture render errors', done => { |
|
|
it('config.errorHandler should capture render errors', done => { |
|
@ -359,6 +359,33 @@ function createErrorTestComponents () { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
components.userWatcherCallbackAsync = { |
|
|
|
|
|
props: ['n'], |
|
|
|
|
|
watch: { |
|
|
|
|
|
n () { |
|
|
|
|
|
return Promise.reject(new Error('userWatcherCallback error')) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
render (h) { |
|
|
|
|
|
return h('div', this.n) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
components.userImmediateWatcherCallbackAsync = { |
|
|
|
|
|
props: ['n'], |
|
|
|
|
|
watch: { |
|
|
|
|
|
n: { |
|
|
|
|
|
immediate: true, |
|
|
|
|
|
handler () { |
|
|
|
|
|
return Promise.reject(new Error('userImmediateWatcherCallback error')) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
render (h) { |
|
|
|
|
|
return h('div', this.n) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// event errors
|
|
|
// event errors
|
|
|
components.event = { |
|
|
components.event = { |
|
|
beforeCreate () { |
|
|
beforeCreate () { |
|
|