Javascript TypeError:无法读取属性'_模块名称空间映射';Vue中未定义的

Javascript TypeError:无法读取属性'_模块名称空间映射';Vue中未定义的,javascript,vue.js,vuejs2,jestjs,vue-test-utils,Javascript,Vue.js,Vuejs2,Jestjs,Vue Test Utils,我创建了一个简单的webapp,使用vue测试Utils和Jest在vue中练习测试技能,但遇到了一个关于vue的错误。我只是在控制台日志中查看我的AddDialog是否在我的主文件中,但有一个错误:这是我的错误: TypeError:无法读取未定义的属性“\u modulesNamespaceMap” 这是我的测试代码 // Imports import Home from '@/components/Home' // Utilities import {createLocalVue, mou

我创建了一个简单的webapp,使用vue测试Utils和Jest在vue中练习测试技能,但遇到了一个关于vue的错误。我只是在控制台日志中查看我的AddDialog是否在我的主文件中,但有一个错误:这是我的错误:

TypeError:无法读取未定义的属性“\u modulesNamespaceMap”

这是我的测试代码

// Imports
import Home from '@/components/Home'
// Utilities
import {createLocalVue, mount,  } from '@vue/test-utils'
import Vue from 'vue'
import Vuetify from 'vuetify'
import AddDialog from "@/components/AddDialog";

Vue.use(Vuetify)

describe('Home.vue', () => {

    const localVue = createLocalVue()
    let vuetify
    beforeEach(() => {
        vuetify = new Vuetify()
    })
    test('creates a todo', async () => {
        const wrapper = mount(Home)
        console.log(wrapper)
    })
})

因为在家中使用存储,但渲染时不使用存储

正如@Raynhour所正确指出的,问题在于没有将
store
添加到测试中。除了这个响应之外,我还将添加一个示例代码段,它修复了使用
Vuex
在我的一个组件中未定义的
TypeError:cannotread属性'\u moduleNamespacemap'

describe("MyComponent.vue", () => {
  let actions: any;
  let getters: any;
  let state: any;
  let store: any;
  let wrapper: any;

  beforeEach(() => {
    actions = {
      sampleAction: jest.fn(),
    };
    getters = {
      sampleGetter: jest.fn(),
    };
    state = {
      sampleState: jest.fn(),
    };

    store = new Vuex.Store({
      modules: {
        requests: {
          namespaced: true,
          actions,
          getters,
          state,
        },
      },
    });
  });

  wrapper = shallowMount(MyComponent, {
    store,
  });

  ... // Some test cases...
});