有人已经获得 @vue/[电子邮件受保护] 来与 @vue/[电子邮件受保护] 合作吗?看起来 test-utils 正在查看 vue@3 模块而不是 vue-compat 模块。
// when I run my tests
● Test suite failed to run
TypeError: Cannot set property 'productionTip' of undefined
> 1 | import { shallowMount } from '@vue/test-utils'
| ^
来自 vue-test-utils.js。
Vue_default
可能是 vue3,因为 config
已被弃用?
Vue__default['default'].config.productionTip = false; //
在 dev 中运行应用程序似乎工作正常,因为 webpack 将“vue”映射到 compat。也许有类似的东西
jest.config
?
// this is what's working for webpack.
declare module 'vue' {
import { CompatVue } from '@vue/runtime-dom'
const Vue: CompatVue
export default Vue
export * from '@vue/runtime-dom'
const { configureCompat } = Vue
export { configureCompat }
}
在 jest.config moduleNameMapper 中将 vue 映射到 @vue/compat 会产生不同的问题
'moduleNameMapper': {
'^vue$': '@vue/compat',
},
// error when running tests
TypeError: 'set' on proxy: trap returned falsish for property '$emit'
这个问题你猜出来了吗?我击中了同一个拦截器