Testing Dialogs with Vitest and Teleported Wrapper not Working #17084
-
Hi all, installQuasarPlugin({ plugins: { Dialog } }); // also tried without the param
...
describe('WidgetDialog', () => {
it('mounts component', () => {
const wrapper = mount(WidgetDialog);
const portalWrapper = wrapper.findComponent({ name: 'QPortal' });
expect(portalWrapper.exists()).toBe(true);
});
}); results in These are my dependencies: "dependencies": {
"@quasar/extras": "^1.16.10",
"pinia": "^2.1.7",
"quasar": "^2.15.2",
"vue": "^3.4.21",
"vue-component-type-helpers": "^1.8.27",
"vue-echarts": "^6.6.9",
"vue-i18n": "^9.10.2",
"vue-router": "^4.3.0"
},
"devDependencies": {
"@intlify/vite-plugin-vue-i18n": "^7.0.0",
"@pinia/testing": "^0.1.3",
"@quasar/app-vite": "^1.8.0",
"@quasar/quasar-app-extension-testing": "^2.2.0",
"@quasar/quasar-app-extension-testing-unit-vitest": "^0.3.1",
"@types/node": "^20.12.2",
"@vitest/coverage-v8": "^0.34.6",
"@vitest/ui": "^0.34.7",
"@vue/test-utils": "^2.4.5",
"autoprefixer": "^10.4.19",
"prettier": "^3.1.1",
"typescript": "5.3.3",
"vitest": "^0.34.6"
},
"engines": {
"node": "^20 || ^18 || ^16",
"npm": ">= 6.13.4",
"yarn": ">= 1.21.1"
},
"resolutions": {
"vite": "^3.2.10",
"@vitejs/plugin-vue": "^3.2.0"
} Am I doing something wrong? I hope, there is an easy solution. Thanks in advance! Best regards from Germany |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
I really hoped this would finally work with the new versions of vitest testing dependencies coming with app-vite2.0, however it still doesn't work. @rstoenescu do you have an idea or hint what I am doing wrong? |
Beta Was this translation helpful? Give feedback.
-
Same problem here, I also hoped that the major vitest update will fix it :'( |
Beta Was this translation helpful? Give feedback.
-
I have the same problem |
Beta Was this translation helpful? Give feedback.
-
Faced the same issue. It works for me with modelValue property describe('WidgetDialog', () => {
it('mounts component', async () => {
const wrapper = mount(WidgetDialog, {
props: {
modelValue: true
}
});
await nextTick()
const portalWrapper = wrapper.findComponent({ name: 'QPortal' });
expect(portalWrapper.exists()).toBe(true);
});
}); |
Beta Was this translation helpful? Give feedback.
Ah sorry, that's my fault. I see the mistake now, 2nd parameter is not props itself. Attached completed working variant.