My limited brain sometimes has trouble interpreting diffs of arrays of trees of nodes.
I find out outputs from jest
like the following to be hard to understand:
Error: expect(received).toEqual(expected) // deep equality
- Expected - 0
+ Received + 5
@@ -1,10 +1,15 @@
Array [
Object {
"children": Array [
Object {
"children": Array [],
+ "textValue": "",
+ "type": Symbol(WHITESPACE),
+ },
+ Object {
+ "children": Array [],
"textValue": "Suivie d'une ligne de texte.",
"type": Symbol(TEXT),
},
],
"textValue": "Une introduction",
I do understand them, but that's not a natural representation for me and causes me a lot of effort.
Is there a way to tell jest
to report deep-equality checks failures with a diff and / or also showing the full received object and the full expected object side by side ?
When the objects are not too big, my ideal error report would be:
My current workaround when I can't wrap my head around a diff is to use the debugger, but it would be nice if I could avoid this step.
As mentioned in a comment to the question, there's a command-line argument --expand
that does more or less that.
It does not separate out the expected vs received presentation, but the diff presentation includes the entire context (all lines before and after the affected ones).