Closed lizhongyue248 closed 4 years ago
不直接使用依赖本身是因为没有 localstorage 吗 https://stackoverflow.com/a/32911774
是因为单元测试里面是使用的 shallowmount
,不会去加载模块依赖。所以只能 mock
vuex-along
模块,但是他是使用 import createVuexAlong from 'vuex-along' 进行导入的,不知道如何mock
createVuexAlong` 这个方法。
有试过 jest.mock('vuex-along', () => () => {})
吗,因为 vuex 插件需要的是个函数
感谢!使用 jest.mock('vuex-along', () => () => {})
mock 通过!~
哈哈 没事 ,新年快乐
通过
jest.mock('vuex-along')
无法 mock,通过jest.mock('vuex-along', () => {})`
mock
import
的部分通过了,但是调用的那里就会报错了。。。请问下如何 mock 比较好呢?谢谢~