testing-library / vue-testing-library

🦎 Simple and complete Vue.js testing utilities that encourage good testing practices.
http://testing-library.com/vue
MIT License
1.07k stars 111 forks source link

provide , inject feature #254

Closed navidshad closed 2 years ago

navidshad commented 2 years ago

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

sand4rt commented 2 years ago

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: {
        ...
    }
  }
})
navidshad commented 2 years ago

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

sand4rt commented 2 years ago

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:)

slacktracer commented 1 year ago

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