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.
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:
Test:
Error:
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
.