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
JsonApprovals.verifyAsJson fails when fields are not in the same order between tests #301
Comments
if the order is different, the approval will fail. |
I can confirm that the behavior that you describe in the first sentence is what I'm also seeing. Indeed, I want the approval to pass if the ordering of the JSON fields changes. Or I'd like a way to control if the verify is lenient regarding ordering. GSONBuilder doesn't offer that |
with release 18.5.0 (releasing right now) there is now a new configuration for
So your custom implementation would probably have to read files a and b into a JsonObject from gson and then does gson offer an |
Data that I use:
Map<String, String> test = new HashMap<>(); test.put("2test", "test"); test.put("1test", "test");
when I use JsonApprovals.verifyAsJson, it creates an output file as expected.
However, if I sort the keys in the map (test1, test2), the test fails. Since JSON field order is not mandatory, I think that the test should be passing.
What do you think?
The text was updated successfully, but these errors were encountered: