Skip to content

Commit d0c13c7

Browse files
committed
test undefined method warning
1 parent 724a593 commit d0c13c7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Diff for: src/core/instance/state.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function initMethods (vm: Component) {
145145
if (methods[key] != null) {
146146
vm[key] = bind(methods[key], vm)
147147
} else if (process.env.NODE_ENV !== 'production') {
148-
warn(`The method ${key} on vue instance is undefined.`, vm)
148+
warn(`Method "${key}" is undefined in options.`, vm)
149149
}
150150
}
151151
}

Diff for: test/unit/features/options/methods.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,13 @@ describe('Options methods', () => {
1515
vm.plus()
1616
expect(vm.a).toBe(2)
1717
})
18+
19+
it('should warn undefined methods', () => {
20+
new Vue({
21+
methods: {
22+
hello: undefined
23+
}
24+
})
25+
expect(`Method "hello" is undefined in options`).toHaveBeenWarned()
26+
})
1827
})

0 commit comments

Comments
 (0)