-
Notifications
You must be signed in to change notification settings - Fork 668
Binded props for stubs in wrapper HTML #640
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
In the next release all stubbed components will render as their tag name with a const TestComponent = {
template: '<some-component prop="yes" />',
components: {
SomeComponent
}
}
mount(TestComponent).html() // <some-component-stub prop="yes" /> Does that satisfy your feature request? |
And what complex prop types ? |
Ah sorry I missed that part of your feature request. Currently they will be rendered as an object, we could investigate calling JSON.stringify on the attributes like you have. My initial concern is handling circular references and checking that a prop object equals the object you passed in. |
We could only change how the component is stringified ?
It should not be vue test utils concern to check circular references of props passed to component. At the beginning I wanted to do it myself but I have to confess I have no idea where those features are handled. With some hints I may help. |
Is there a flag for not rendering the props? I have a ton of snapshot tests that are now failing because the mocked date being set as a prop is rendering to a string in UTC on the CI server but EDT on our dev machines. (dates suck) |
@jbosse there isn't yet, if you would like this feature you can make a feature request and we will consider adding one 👍 |
Yesterday I discovered a snapshot serializer package. Perhaps I can use that or something similar to configure how Dates are serialized for these. At the moment I have monkeypatched date tostring to output something I can control across environments. Or I can fork fix and PR :-) |
What problem does this feature solve?
As a member of front developper with React Framework, we did a lost of tests on our components with Enzyme.
In order to have "Unit tests" we mainly use "Shallow" rendering feature to test our components.
Coupled with Jest snapshot checks, it made our test very easy and quick to write.
We tried to apply those usage with Vue and test utils but we were confronted to lacks of feature:
We would often want to have a stub component with name of component as tag. In the current state of the API, we have to define a stub for every childComponent to have a humanly readable tag in
.html()
Object
in tagsNot printable props type are not showing well in
.html()
generated. For example withObject
types.What does the proposed API look like?
It could be awesome to have
autoStubs
mounting options with tag generated on child names.It would be very usefull to have readable/comparable props in
html()
rendered.To fill this lack of feature, we developed a utils to generate our stubs and handle props.
Our generateStubs implementation
It generate those kind of html :
The text was updated successfully, but these errors were encountered: