Nuxt的Vue测试工具-提交突变

时间:2020-07-20 16:07:23

标签: vue.js vue-test-utils

我在nuxt上使用vue test utils,我有标准突变

 this.$store.commit(
        'users/UPDATE_NAME',
        this.username
      )

在我的.spec中,我正在尝试访问此突变,但出现错误

TypeError:无法读取未定义的属性“ commit”

我也尝试过嘲笑它

   it("It should commit the change name mutation", () => {
    
      const wrapper = shallowMount(ChangeName, {
        mocks: {
          $store: {
            // what goes here
          }

但是不知道如何设置包装器,因此它可以访问模块“用户”中的突变

  this.$store.commit('users/UPDATE_NAME',this.username)

如何设置.spec以访问此突变?

0 个答案:

没有答案