【发布时间】:2019-05-06 08:43:52
【问题描述】:
我正在尝试按照此处列出的配置抑制我的测试中的警告:https://vue-test-utils.vuejs.org/api/config.html#silent,如下所示:
import { config } from '@vue/test-utils';
// this should actually be the default but the default is not working
config.silent = true;
但是,我仍然在测试结果中看到警告:
TheQueue
✓ should show the queue bar if there are items queued
✓ should show the correct count of queued items in queued bar
[Vue warn]: Avoid mutating a prop directly since the value will be
overwritten whenever the parent component re-renders. Instead, use a
data or computed property based on the prop's value. Prop being
mutated: "mdTemplateData"
found in
---> <MdTab>
<MdContent>
<MdTabs>
<MdDrawer>
<TheQueue> at src/components/the-queue/TheQueue.vue
<Root>
值得注意的是,我在应用程序的正常使用中没有看到此错误。这只会在测试中弹出(否则我会尝试修复实际建议的问题)。
我在这里做错了什么,为什么我不能取消这些警告?还是我误解了silent 应该做什么?
【问题讨论】:
-
我也在尝试在单元测试中静默 Vue 警告,但据我阅读
vue-test-utilssource code 了解,此silent配置属性仅在您使用setPropsmethod 时触发你的测试。 -
这方面有什么进展吗?我也有同样的问题
-
我知道你在 6 个月前问过,但我现在才看到你的问题,希望对你有帮助
标签: vue.js vue-test-utils