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.08k stars 109 forks source link

Passing data to a component using the composition api #300

Closed Jefry16 closed 1 year ago

Jefry16 commented 1 year ago

When unit testing a component that uses the options API I could pass options like this:

render(Component, {
      data() {
        return { title: "buzzfeed" }
      },
    })

Now that I use the composition API I dont have the option, I mean, the option is there but it does not change in the template as before. What is the way to do it now?

afontcu commented 1 year ago

Hi!

Vue Testing Library exists to make these kind of tests (passing arbitrary data to a component) irrelevant, and instead focusing on interacting with a component as a user would: https://github.com/testing-library/vue-testing-library#guiding-principles

with that in mind, the fact that the composition API does not allow to pass in this kind of data is a feature for this library, not a bug.

Thanks!