testing-library/vue-testing-library

provide , inject feature

navidshad opened this issue · 4 comments

HI everyone
is there any way to test provide/inject feature of vue components in vue-testing-component?

Hi @navidshad, yes there is. The provide object is re-exposed from the vue-test-utils library. You can use it like the code below:

render(Component, {
  global: {
    provide: {
        ...
    }
  }
})

oh amazing, I use typescript but this parameter is not in types

I also use TypeScript and i see that the paramater is typed. Note that provide is wrapped with global. Please let the author known if you found the solution so he (or you) can close the issue:)

Is this somewhere in the docs? I tried to use it as Vue Test Utils docs say it is used and they say nothing about wrapping in this global property object... 🤔