-
Notifications
You must be signed in to change notification settings - Fork 668
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
Pretty-print html() output by default #1147
Comments
For snapshot tests, I recommend using the DOM element: expect(wrapper.element).toMatchSnapshot() |
Thank you for your recommendation Edd. I'm sorry that I forgot to mention that I'm mounting/testing the components in Chrome with Puppeteer using |
I think you can just use diffable-html in your tests |
I needed this too in my test! @eddyerburgh if anyone isn't actively looking into this, I'm interested to work on this, but I guess we might have to agree on the API, whether it's |
@briwa @eddyerburgh I have a tentative Pull Request for this feature. Are there any preferences on |
@addisonssense I'd vote for |
I prefer |
I have created a PR to resolve this issue. I welcome feedback :) |
Thinking about it more, I think it should pretty print by default. Vue Test Utils is still in beta so we can make breaking changes now. |
Please see: eddyerburgh/jest-serializer-vue#13 |
What problem does this feature solve?
My team is using
@vue/test-utils
for snapshot testing components but the snapshots are hard to parse because the HTML string output from.html()
is not formatted in a readable way. Ifhtml()
pretty-printed the HTML it would be a lot easier to review changes to the component-generated HTML.What does the proposed API look like?
html()
would pretty-print the returned HTML string by default, perhaps using something like https://github.com/prettydiff/prettydiff. If necessary, a user could bypass pretty-printing by passing an option to.html()
, perhaps.html(false)
or.html({ prettyPrint: false })
.The text was updated successfully, but these errors were encountered: