.should('deep.equal') does not show a full diff comparison on failures
See original GitHub issueCurrent behavior:
Cypress does not show enough information to know what is the difference when deep comparing complex objects.
Example:
cy
.wrap({ foo1: { bar: { foo1: { bar: 1 } } }, foo2: { bar: 1 } })
.should('deep.equal', { foo1: { bar: { foo1: { bar: 1 } } }, foo2: { bar: 2 } })
Result:
Desired behavior:
Ideally, I’d like cypress to show a complete diff of the compared objects so we can easily spot the difference.
Versions
cypress@3.2.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:22
- Comments:18 (2 by maintainers)
Top Results From Across the Web
Is there any way to see a diff on a deep equal assertion ...
It would be fantastic to actually see the differences instead of seeing: expected [ Array(3) ] to deeply equal [ Array(3) ]. I...
Read more >Can't Cypress tell me what the exact difference is?
When I run a test via the Cypress GUI I get a report (left in the image) and it tells me that my...
Read more >Comparing objects and sequences - Testfixtures
When using compare() frequently for your own complex objects, it can be beneficial to give more descriptive output when two objects don't compare...
Read more >Assert | Node.js v19.3.0 Documentation
For example, assert.deepEqual() will behave like assert.deepStrictEqual() . In strict assertion mode, error messages for objects display a diff. In legacy ...
Read more >API Reference
'bar', 'foo is not bar'); assert(Array. ... isNotOk('everything', 'this will fail'); assert. ... Assert that actual is not deeply equal to expected ....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@braveheart55 @tsvetan-ganev @gurudattgd04 If you are interested, here is a work-around that a friend of mine (@Bushwazi) came up with that we are using:
In our
/support/index.js
: we intercept and override our chaiexpect(expected).to.deep.equal(actual)
lines across all of our testsNotes
console.log()
and check the console instead of in-line printing it in the test runner as well.It will look like this:
I’ve also been following this issue for 3 years+.
I understand Cypress is geared more towards UI-testing than API-testing (For example, I don’t need a ViewPort if I’m just testing a JSON REST API, yet there is no flag to turn this off), but they really should start adding some quality of life changes for API-only testing.
It would be great if there was an
API_ONLY_TESTING
flag or something similar. I bet they can turn off a bunch of UI-only functionality – and improve Cypress performance and responsiveness if you are just testing a REST API.Showing a more detailed diff of objects in the error message is part of this larger issue, that is currently in progress: https://github.com/cypress-io/cypress/issues/3762 You can see an comment on our planned designs there.
Will leave this open as part of that epic.
You can also click on the
Assert
command in the Command Log to see a fully diff within your DevTools console.