Feature request as suggested in https://github.com/vuejs/vue-test-utils/issues/271#issuecomment-356690053
Please add support for HTML templates. Main use case is Vue single file components. Example of unsupported use case:
https://jsfiddle.net/h0bnmk5d/1/
And the current work around is to refactor into component template property:
Is this something that's going to be included? Testing seems to steer the way we're write code in other contexts. Developers steering away from HTML templates and towards using a main App component is common from what I can tell. It doesn't really seem to create that much more work either.
I thought it would be a nice-to-have.
You're right, we should encourage users to use templates in components, rather than HTML templates. But HTML templates make Vue more accessible for users, and the ability to drop vue-test-utils into a codepen of a Vue instance with an HTML template might make testing more approachable to some users.
My 2 cents is that if this is to be the official testing library of Vue, it should support all features of Vue (or at least the main ones, of which HTML templates and single file components are in my opinion).
What is the work around for this? Do we have to completely refactor our html templates into a template property? Why is there documentation on testing single file components if it isn't fully supported?
Having waded through mud to try to test Vue components only to hit this issue with $refs I feel rather deflated to find I have to refactor templates into properties to make this work - especially as they do not have the same editor syntax checking that html templates have.
We recently merged a PR, which allows templates as a reference in the element in the DOM - #1320
Closing for now.
Most helpful comment
My 2 cents is that if this is to be the official testing library of Vue, it should support all features of Vue (or at least the main ones, of which HTML templates and single file components are in my opinion).