[Vuejs]-How to test a vue method with mocha Chai

2👍

The method would simply be defined as a property of the wrapper.vm, so you could verify the method exists with:

expect(wrapper.vm.getUsers).to.be.a("function")
👤tony19

2👍

Could you do something like

const result = typeOf wrapper.vm.$methods.getUsers();

Then test the result is a string with value “function”?

expect(result).to.equal("function");

Is that any use to you?

Leave a comment