MartinMalinda / vue-concurrency

A library for encapsulating asynchronous operations and managing concurrency for Vue and Composition API.

Home Page:https://vue-concurrency.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Errors while testing

lukaiser opened this issue · comments

When testing a component with "@testing-library/vue"

describe('App.vue no webinars', () => {
  it('shows no webinars', async () => {
    mocked(getWebinarsApi).mockResolvedValueOnce({ data: [] })
    const { getByText } = render(Component)
    getByText('Aktuell sind keine Webinare verfügbar.')
  })
})

I get the following error:

[Vue warn]: Error in render: "TypeError: Cannot read property 'isError' of undefined"
     
     found in
     
     ---> <Anonymous>
            <Root>

isError is called on a task passed to the template.

<q-card-section v-if="getWebinars.isError">
    ...
</q-card-section> 

Running the component in the browser works fine.
Apparently, my task isn't available in the template at that time.

Does anybody have an idea, why that might be the case?

Thanks for the help!!!

PS: same problem with @vue/test-utils
PPS: I am using Vue 2 with @vue/composition-api

Is the task passed via props? Or is the component itself creating it? But I guess you're testing entire App component right? So the test is passing no props. Could be a routing issue maybe? I'd dare to guess this isn't really too vue-concurrency related and the issue is somewhere else, it just happened to blow up here.

The component itself is creating it... And you are right, it has nothing to do with vue-concurrency. Reactive isn't working either. Thanks for thinking about it :)