Vue 单元测试 - 模拟插件 return 值

Vue Unit Testing - Mocking a plugins return value

我有一个自定义插件,return是一个布尔值。我不想将插件导入测试,而是想模拟这个值。我可以很容易地模拟插件,但是如何更改测试中的 return 值?

const $mq = () => {};    
wrapper = shallowMount(Component, { 
  //...
  mocks: {
    $mq
  }
  //...
});

测试

it ('Test description', () => {
  wrapper.vm.$mq = () => true; // HOW TO MOCK PLUGIN RETURNS???
});

如果有人遇到这种情况,您需要在将其提供给 mocks 选项之前更改该值。

const $mq = () => true;    
wrapper = shallowMount(Component, { 
  //...
  mocks: {
    $mq
  }
  //...
});