Vue unit test error: expected [Function: proxy] to be false

Vue unit test error: expected [Function: proxy] to be false

Vue unit test error: expected [Function: proxy] to be false

Vue组件中的函数为:

data(){
   return{
      showcart:false
   }
}

methods:{
   closedialoguebox: function() {
      return (this.showcart = false);
   }
}

相应功能的单元测试用例是:

它('closedialoguebox function should close the dialogue box when clicked on home', () => {

const Mockedshowcart = false
const someStub = sinon.stub(wrapper.vm,'closedialoguebox').returns(Mockedshowcart)
expect(someStub).to.be.false

}) }

我得到的错误是:

× closedialoguebox function should close the dialogue box when clicked on home
    expected [Function: proxy] to be false

提前致谢

someStub 是 returns false 的函数。 您的测试用例没有调用函数 someStub。添加括号以调用函数。正确的说法是:

expect(someStub()).to.be.false