Vue.js Jest无法加载模块vue cookies

Vue.js Jest无法加载模块vue cookies,vue.js,jestjs,Vue.js,Jestjs,this.$cookies由名为vue cookies 我已将其安装并保存在我的devdependences中,但jest似乎无法找到或加载它 我不确定我必须做什么来确保Jest正确加载这些模块。使用Jest进行测试意味着是自包含的。这意味着像这样的全局对象。$cookies不可用,因为它们与浏览器中的cookies交互。解决这个问题的方法是模拟全局函数。有关如何执行此操作的更多信息,请单击此处: console.error node_modules/vue/dist/vue.runtime.

this.$cookies
由名为
vue cookies

我已将其安装并保存在我的devdependences中,但jest似乎无法找到或加载它


我不确定我必须做什么来确保Jest正确加载这些模块。

使用Jest进行测试意味着是自包含的。这意味着像这样的全局对象。$cookies不可用,因为它们与浏览器中的cookies交互。解决这个问题的方法是模拟全局函数。有关如何执行此操作的更多信息,请单击此处:

console.error node_modules/vue/dist/vue.runtime.common.dev.js:621
  [Vue warn]: Error in mounted hook (Promise/async): "TypeError: Cannot read property 'get' of undefined"

  found in

  ---> <Anonymous>
         <Root>
console.error node_modules/vue/dist/vue.runtime.common.dev.js:1884
  TypeError: Cannot read property 'get' of undefined
      at VueComponent.mounted (/home/ubuntu/vue-testing-skel/src/components/ChatApp.vue:66:1)
    this.current_nickname = this.$cookies.get('nickname')