chaijs / chai

BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.
https://chaijs.github.io
MIT License
8.11k stars 694 forks source link

Better user experience when using `.include` without `.deep`. #1619

Open koddsson opened 3 months ago

koddsson commented 3 months ago

Given the following assertion:

expect({ tags: {} }).to.include({ tags: {} });

You get the following assertion error:

AssertionError: expected { tags: {} } to have property 'tags' of {}, but got {}

For those of us that have read the guide know that I really want to do:

expect({ tags: {} }).to.deep.include({ tags: {} });

According to the guide using .deep:

Causes all .equal, .include, .members, .keys, and .property assertions that follow in the chain to use deep equality instead of strict (===) equality. See the deep-eql project page for info on the deep equality algorithm: https://github.com/chaijs/deep-eql.

This isn't obvious from the usage though. I wonder if we could improve the user experience by point the user towards .deep in the assertion error?