unit-testing - 测试具有 vuex 的 vue 组件
问题描述
我无法使用其中的 vuex 测试我的 vue 组件。
这是我的 mapGetters 之一
方法
listaSatelite() {
if (this.getCropsSelected._id!=undefined) {
}}
这是我得到的错误:
Cannot read property '_modulesNamespaceMap' of undefined
计算的
...mapGetters("property",["getCropsSelected"]),
我的规格文件
import {shallowMount,createLocalVue} from '@vue/test-utils'
import Vuex from 'vuex'
import sateliteComponent from '@/components/satelite/listaSatelite.vue'
import sateliteStore from '@/core/modules/satelite/index.js'
var vueWithVuex = createLocalVue()
vueWithVuex.use(Vuex)
const store = new Vuex.Store({
sateliteStore
})
describe('testes componente satelite', () => {
test('instanciado', () => {
const wrapper = shallowMount(sateliteComponent)
console.log(wrapper)
});
});
错误日志
TypeError: Cannot read property '_modulesNamespaceMap' of undefined
119 | },
120 | listaSatelite() {
> 121 | if (this.getCropsSelected._id!=undefined) {
| ^
122 | this.listSatelite({
123 | startDate: this.getCropsSelected.startDate,
124 | endDate: this.getCropsSelected.endDate
在我的控制台中,它指向并显示错误在方法中,好像他无法导入或找到这个 getter
我不确定我做错了什么,欢迎任何帮助!如果有人有关于如何使用vuex测试vue的教程,但是测试组件,我在互联网上找到的是vuex本身的测试
解决方案
推荐阅读
- javascript - 有没有一种简单的方法可以在 d3.csvParse 遇到空行时停止它?
- python-3.x - 不明白为什么服务器不会响应客户端(即使在打开防火墙后 | Python | 服务器
- sql - 选择行,对于 A 列中的相同值,B 列在所有行中都具有特定值
- c - 为什么在 C 中使用链表前端元素错误获取优先级队列?
- python-3.x - `on_typing` 事件在 self bot discord.py 上不起作用
- r - 无法在闪亮应用程序的 lapply 函数中使用应用函数
- .net - 私有 nuget 源 github 返回 401 并具有正确的凭据
- reactjs - 在同一组件上具有不同路径的 React Router:不重新初始化组件(未调用 useEffect [])
- git - 什么会导致 git log 显示新的提交消息但带有原始哈希?
- mysql - mysql表上SQL select *后没有返回数据