1 回答
TA贡献2037条经验 获得超6个赞
解决了!
将我的 .spec.ts 文件更改为 .spec.js,并将内容更改为如下内容:
import { mount, createLocalVue, shallowMount } from '@vue/test-utils';
import * as All from 'quasar';
import dbRequest from 'src/boot/aao';
const { Quasar, date } = All;
const components = Object.keys(All).reduce((object, key) => {
const val = All[key];
if (val && val.component && val.component.name != null) {
object[key] = val;
}
return object;
}, {});
describe('Mount Quasar', () => {
const localVue = createLocalVue();
localVue.use(Quasar, { components });
// Here's the solution, the global functions need to be used by the local vue component
localVue.use(dbRequest);
const wrapper = mount(UserMyProfile, {
localVue,
});
const vm = wrapper.vm;
// Tests here
}
在此处阅读更多信息: https ://vue-test-utils.vuejs.org/guides/common-tips.html#applying-global-plugins-and-mixins
添加回答
举报