ApprovalTests.Java
ApprovalTests.Java copied to clipboard
verifyXml() escaping behaviour
I'm working with Jackson to generate some XML that I'd like to then approve with the verifyXml() method. Jackson takes care of escaping special characters in the XML but doesn't pretty print it. I'm finding some inconsistencies with how Approvals then formats the XML:
- Single quotes in the DTD are being converted to double quotes. This isn't a major issue but is a difference between what Jackson outputs and how Approvals then formats it.
- Emoji characters, which Jackson doesn't escape, are being escaped by Approvals. For example, "😼" is being output as 😼
- XML special characters, which Jackson has already escaped, are being escaped again. For example, Jackson outputs
&but Approvals then changes this to&amp.
Do you have any comments on this? Is it possible to just apply formatting to the XML string that adds line breaks and indents but without further formatting the content?
- would you be willing to join us on a zoom call to work on this?
- do you have a unit test we can look at to see the issues?
Happy to join you on a Zoom call to look into this. I don't have a unit test yet but I can look to add one today.
I'm wondering if a similar approach to JsonJacksonApprovals would work here too.
Added a draft pull request #473 with a couple of tests to show the discrepancies I'm seeing. Strangely, I couldn't verify that & is being converted to &, even though I saw this in my own codebase a few weeks ago.
Please send an email to [email protected] and he'll forward you the invite for our next session. Looking forward to it!