|
|
@@ -11,7 +11,8 @@ describe('Error handling', () => {
|
|
|
['render', 'render function'],
|
|
|
['beforeCreate', 'beforeCreate hook'],
|
|
|
['created', 'created hook'],
|
|
|
- ['beforeMount', 'beforeMount hook']
|
|
|
+ ['beforeMount', 'beforeMount hook'],
|
|
|
+ ['directive bind', 'directive foo bind hook']
|
|
|
].forEach(([type, description]) => {
|
|
|
it(`should recover from errors in ${type}`, done => {
|
|
|
const vm = createTestInstance(components[type])
|
|
|
@@ -32,7 +33,8 @@ describe('Error handling', () => {
|
|
|
// error in beforeUpdate/updated should affect neither child nor parent
|
|
|
;[
|
|
|
['beforeUpdate', 'beforeUpdate hook'],
|
|
|
- ['updated', 'updated hook']
|
|
|
+ ['updated', 'updated hook'],
|
|
|
+ ['directive update', 'directive foo update hook']
|
|
|
].forEach(([type, description]) => {
|
|
|
it(`should recover from errors in ${type} hook`, done => {
|
|
|
const vm = createTestInstance(components[type])
|
|
|
@@ -45,7 +47,8 @@ describe('Error handling', () => {
|
|
|
|
|
|
;[
|
|
|
['beforeDestroy', 'beforeDestroy hook'],
|
|
|
- ['destroyed', 'destroyed hook']
|
|
|
+ ['destroyed', 'destroyed hook'],
|
|
|
+ ['directive unbind', 'directive foo unbind hook']
|
|
|
].forEach(([type, description]) => {
|
|
|
it(`should recover from errors in ${type} hook`, done => {
|
|
|
const vm = createTestInstance(components[type])
|
|
|
@@ -173,6 +176,22 @@ function createErrorTestComponents () {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+ // directive hooks errors
|
|
|
+ ;['bind', 'update', 'unbind'].forEach(hook => {
|
|
|
+ const key = 'directive ' + hook
|
|
|
+ const dirComp = components[key] = {
|
|
|
+ props: ['n'],
|
|
|
+ template: `<div v-foo="n">{{ n }}</div>`
|
|
|
+ }
|
|
|
+ const dirFoo = {}
|
|
|
+ dirFoo[hook] = function () {
|
|
|
+ throw new Error(key)
|
|
|
+ }
|
|
|
+ dirComp.directives = {
|
|
|
+ foo: dirFoo
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
// user watcher
|
|
|
components.userWatcherGetter = {
|
|
|
props: ['n'],
|