quasarframework / quasar-testing

Testing Harness App Extensions for the Quasar Framework 2.0+
https://testing.quasar.dev
MIT License
179 stars 65 forks source link

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

Closed jeffrey-noel closed 9 months ago

jeffrey-noel commented 1 year ago

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.

IlCallo commented 11 months ago

Are you still hitting this problem? I guess it's the same problem of this issue: https://github.com/quasarframework/quasar-testing/issues/333

IlCallo commented 9 months ago

Closing due to a lack of response