我试图在 vue3 中使用 jest 和 quasar 进行单元测试,但出现以下错误
失败测试/T1/views/xyz.spec.ts ● 测试套件运行失败
TypeError:无法读取未定义的属性(读取“dark”)
我在类星体中使用了深色和浅色模式来改变屏幕的背景颜色 但出现错误
dark
请帮助我
我在 vuejs 3 + Quasar + vite 项目中使用 vitest 运行单元测试时遇到了这个错误。解决方案是将 Quasar 添加到测试套件中的
global.plugins
选项中
import { config, mount } from '@vue/test-utils';
import MyComponent from './../components/MyComponent.vue';
import { Quasar } from 'quasar';
config.global.plugins = [Quasar];
test('it renders'), () => {
const wrapper = mount(MyComponent);
};