Inconsistent behaviour when using components from an AE's provided UI Kit that extend Quasar components when run in Vitest
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- typescript
Direzione di ricerca
Build the UI portion of quasar-test-ui with npm run build, then run npm run test:unit in quasar-test-app. Compare the q-btn and q-btn-dropdown cases with the corresponding my-button and my-button-dropdown cases under tests/vitest/*. Done means wrapped components register clicks and avoid the reported Platform plugin error in Vitest.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
When using a Quasar app extension that provides UI components that extend Quasar components, the components exhibit mixed behaviour when run inside a Vitest testing environment (which they do not exhibit when simply used in a host app).
Example
Writing a simple test that uses q-btn to increment a counter with clicks works fine and tests pass. However, switching these components with ones from an AE's UI Kit (i.e. my-button) that do nothing but return a q-btn from their render function causes the click function to no longer get called properly. Similarly, a q-btn-dropdown works fine and tests pass but a custom my-button-dropdown that simply returns a q-btn-dropdown causes a strange error that seems to originate from the Platform plugin.
From app extension's UI Kit:
import { h } from 'vue'
import { QBtn } from 'quasar'
export default {
name: 'MyButton',
setup (props, { attrs}) {
return () => h(QBtn, {
...props,
...attrs,
class: 'my-button'
})
}
}
Simple test case in host app using Vitest
<template>
<div>
<p>{{ title }}</p>
<p>Clicks on button: {{ clickCount }}</p>
<my-button @click="increment" />
<my-button-dropdown @click="increment" />
<q-btn @click="increment" />
<q-btn-dropdown @click="increment" />
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
const props = withDefaults(
defineProps<{
title: string;
}>(),
{
title: 'Hello!',
},
);
const clickCount = ref(0);
function increment() {
clickCount.value += 1;
return clickCount.value;
}
</script>
The test for this case:
describe('example Button', () => {
it('should register a click event and perform it', async () => {
const wrapper = mount(ExampleButton, {
props: {
title: 'Hello'
},
});
expect(wrapper.vm.clickCount).toBe(0);
await wrapper.find('.my-button').trigger('click');
expect(wrapper.vm.clickCount).toBe(1);
});
});
results in:
or this with q-btn-dropdown case:
Reproduction
This issue spans two repos: one for the app extension/UI kit, and another for the Vitest test case that uses the component from the UI kit.
To reproduce:
- Install dependencies and build the
uiportion of thequasar-test-uirepo usingnpm run build - Ensure the
quasar-test-uirepo is properly linked as a dependency in thequasar-test-appand install dependencies - Run
npm run test:unitin thequasar-test-appand play around with the examples commented in/out under thetests/vitest/*directory (switchq-btnformy-button,q-btn-dropdownformy-button-dropdown, etc)
- Lingua principale
- TypeScript
- Stelle
- 184
- Fork
- 67
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di quasarframework/quasar-testing
-
Support for Cypress 16Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Automatically scaffold vitest-eslint-config and provide guidance on how to set it up properlyAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
Proposal: Improve portal dependent components (e.g. QSelect , QButtonGroup etc) testing experienceAperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
quasarframework/quasar-testing#355 · 1 commento ·
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
Tutte le issue di quasarframework/quasar-testing
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
tenstorrent/ttnn-visualizer#2526 ·
I maintainer di solito rispondono entro 1 giorno
-
trySessionCache calls /get-session twice when minting session_data (cache miss or expired cookie)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
neondatabase/neon-js#301 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
tashfeenahmed/freellmapi#2305 ·
I maintainer di solito rispondono entro 1 giorno