quasarframework / quasar-testing

Testing Harness App Extensions for the Quasar Framework 2.0+

Home Page:https://testing.quasar.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot destructure property 'proxy' of 'getCurrentInstance(...)' as it is null.

jeffrey-noel opened this issue · comments

  • 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.

Are you still hitting this problem?
I guess it's the same problem of this issue: #333

Closing due to a lack of response