https://kotlinlang.org logo
#kotest-contributors
Title
# kotest-contributors
s

sam

09/26/2021, 3:13 PM
@Emil Kantis what do you think about https://github.com/kotest/kotest/issues/2541
e

Emil Kantis

09/26/2021, 4:16 PM
I think we have that to some extent? Do you have a particular case we can look at? 🙂
Or do we just show the first property that failed?
s

sam

09/26/2021, 4:25 PM
We currently show expected was .... actual was .... but for large json its really difficult to see where they differ
maybe we keep that and yeah show the first property (or few) that failed along with the json path to them ?
that would be sweet
e

Emil Kantis

09/26/2021, 4:26 PM
I’ll have a look 🙂
s

sam

09/26/2021, 4:26 PM
cool
j

Jim

09/26/2021, 7:34 PM
Could we build a git style diff?
s

sam

09/26/2021, 7:45 PM
With the + -
e

Emil Kantis

09/26/2021, 8:23 PM
Isn't that kind of what IntelliJ already produces from the "expected was...", "actual was..."?
at least if we do it with the
expected was <[ { ... }]>, actual was <[ { ... }]>
format? 🤔
s

sam

09/26/2021, 8:25 PM
it won't be as clear tho
like if a field was missing
but certainly better
we could do both
e

Emil Kantis

09/26/2021, 8:26 PM
I guess it gets complicated when not being strict in every regard.. e.g. allowing different number formats, type coercion, etc.. then diffs will pop up that don't actually matter as well
I'll start with the property-printing with json-paths you suggested, and then we can go for another round of feedback once I'm a bit more up-to-speed on it?
s

sam

09/26/2021, 8:29 PM
sure
e

Emil Kantis

09/26/2021, 9:07 PM
We currently show expected was .... actual was .... but for large json its really difficult to see where they differ (edited)
Was this when using
shouldMatchJson
or
shouldEqualJson
, (or their underlying matchers)? just asking since i saw you used
matchJson
in your PR which would not print any help other than expected vs actual
Example test of `equalJson`: shows path to a missing field, for instance
Copy code
test("real world json without field") {
         val a = this::class.java.getResourceAsStream("/shopify.json").bufferedReader().readText()
         val b = this::class.java.getResourceAsStream("/shopify_without_field.json").bufferedReader().readText()
         shouldFail {
            a shouldEqualJson b
         }.message.shouldStartWith(
            """At 'products.[0].variants.[0]' object was missing expected field(s) [sku]
s

sam

09/26/2021, 9:21 PM
we should overly format these in my opinion
I'd like to see our error messages in 5.1 go on acid
😄 1
e

Emil Kantis

09/26/2021, 9:27 PM
gotcha 👌
2 Views