testing - 测试Vue.js(^2.5.*)组件时提示prop被突变如何处理

标签 testing vue.js vuejs2

我在测试使用 Vue utils 挂载的组件时遇到以下错误消息:

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: <prop name>

最佳答案

挂载待测组件时,为防止控制台显示错误信息,将sync选项设置为false给mount函数。另见 https://vue-test-utils.vuejs.org/api/options.html#sync

关于testing - 测试Vue.js(^2.5.*)组件时提示prop被突变如何处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54571129/

相关文章:

ruby - 运行 Ruby Selenium 测试用例时出现 "Failed assertion, no message given."错误

c# - 如何在 C# 中使用 Selenium 验证是否显示了警报消息?

testing - Angular2 测试 http 服务说不支持 map 功能

javascript - 在 ES6 : "Failed to resolve module specifier "vue""中导入包

javascript - 为什么 Prettier 不格式化 VS Code 中的代码?

javascript - 我如何最初将幻灯片容器设置为距左边距 10%,并在到达末尾时距右边距 10%? (vue-awesome-swiper)

javascript - 如何提取 `v-for` 表上的函数

testing - 如何在开发过程中检查 SaltStack 的 SLS 文件的语法正确性

javascript - 如何使用 Vue JavaScript 对元素进行分组以添加数组中的数量

javascript - 如何使用 Webpack 从 Vue 路由器生成 sitemap.xml?