TypeError: Cannot destructure property 'proxy' of 'getCurrentInstance(...)' as it is null.
jeffrey-noel opened this issue · comments
Jeffrey Noël commented
- OS: Windows 11
- Node: 16.16.0 (using NVM)
- NPM: 8.11.0 (but using yarn 1.22.19)
- Any other software related to your bug: vue-testing-library, @vue/compat
What did you get as the error?
When I try to run a test with a component using q-btn, I get the following error.
Component:
<script setup lang="ts">
defineProps<{
msg: string;
}>();
</script>
<template>
<div>
<h1>{{ msg }}</h1>
<q-btn label="Test" @click="() => console.log('test')"></q-btn>
</div>
</template>
Test:
import { describe, it, expect } from 'vitest';
import HelloWorld from '@/components/HelloWorld.vue';
import { installQuasarPlugin } from '@quasar/quasar-app-extension-testing-unit-vitest';
import router from '@/router';
import i18n from '@/i18n';
import { render, screen } from '@testing-library/vue';
installQuasarPlugin();
describe('HelloWorld', () => {
it('renders properly', () => {
render(HelloWorld, {
props: { msg: 'This is a test' },
global: {
plugins: [router, i18n],
},
});
expect(screen.queryByText(/This is a test/)).not.toBeNull();
});
});
Error:
TypeError: Cannot destructure property 'proxy' of 'getCurrentInstance(...)' as it is null.
❯ setup ../node_modules/quasar/src/components/btn/QBtn.js:46:13
What were you expecting?
I was expecting my component using q-btn to be testable after I used installQuasarPlugin()
What steps did you take, to get the error?
Here's a repository were you can replicate the error.
https://github.com/Jeffs24/quasar-testing-error
You only need to do a yarn test:unit
.
Paolo Caleffi commented
Are you still hitting this problem?
I guess it's the same problem of this issue: #333
Paolo Caleffi commented
Closing due to a lack of response