chai icon indicating copy to clipboard operation
chai copied to clipboard

how to check component methods calledOnce

Open vaasav-kumar opened this issue 4 years ago • 1 comments

Your document is not clear of testing vue component methods.
I need to check how many times a component method has been called (or) need to check whether the method has been called or not.

vaasav-kumar avatar Dec 08 '20 15:12 vaasav-kumar

Have a look at chai-spies for this. It's a plugin which allows you to do something like this:

const chai = require('chai');
const chaiSpies = require('chai-spies');
chai.use(chaiSpies);

let vm = new Vue({ ... });
chai.spy.on(vm, 'someMethod');
doSomething();

expect(vm.someMethod).to.have.been.called();

sebamarynissen avatar Dec 10 '20 08:12 sebamarynissen