无法使用类星体读取未定义的属性(读取“暗”)vuse3

har*_*ita 5 jestjs quasar-framework vuejs3

我试图在 vue3 中使用 jest 和 quasar 进行单元测试,但出现以下错误

\n

失败测试/T1/views/xyz.spec.ts\n\xe2\x97\x8f 测试套件运行失败

\n

类型错误:无法读取未定义的属性(读取“暗”)

\n

我在类星体中使用深色和浅色模式来更改屏幕的背景颜色\n但出现错误dark\n请帮助我

\n

小智 0

我在 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);
};
Run Code Online (Sandbox Code Playgroud)