-
Notifications
You must be signed in to change notification settings - Fork 112
Cannot set data properties on a component #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi! Thanks for filling in the issue. This is not a bug, since VTL aims for providing the tools that allow you to interact with your components as the end user or the developer would do – neither of them would be able to directly modify the internal data from a component, and this is why VTL does not exposed such method. What's your use case? Maybe we can figure it out 🙌 |
@afontcu In my component there are some api calls within methods on the component. These set certain data attributes, i'm not sure how to mock them as they are hardcoded into the component itself. This is why i'm using the setData method from vue-test-utils in order to set the values. |
You should mock you API calls – https://afontcu.dev/testing-api-calls/ So you can test without hitting a back end, and also reassure that you're getting the desired output from the API call. |
In that example the api calls are in a separate file. My api calls are written into the vue component itself. |
If a test is hard to write, it usually means the component is doing too much, or that it is too coupled. You might benefit from removing responsibilities from it to other parts of your system. Anyway, you can easily mock |
This is true, might refactor the component! Nice one :) |
Thanks for commenting, though! :) Feel free to raise any other issue or ask any question in our Spectrum chat: https://spectrum.chat/testing-library |
Describe the bug
From what i've heard this library is a wrapper around @vue/test-utils, one of the most handy functions I find with that library is the wrapper.setData() method. I cannot do that with this library.
Expected behavior
When rendering a component I should be able to set the data attributes on rendering.
Related information:
@testing-library/vue
version: 4.1.0Vue
version: 2.6.10node
version: 10.16.0npm
(oryarn
) version: 6.9.0The text was updated successfully, but these errors were encountered: