expect(array).to.deep.include({...}) does not apply deep equality recursively
See original GitHub issueAs the title says,
if I run expect(array).to.deep.include(obj)
I would expect to apply deep equality to each of the property of obj
.
But it does not behave like this, is it a bug?
Issue Analytics
- State:
- Created 9 years ago
- Comments:24 (9 by maintainers)
Top Results From Across the Web
Chai deep.include throws Error "Uncaught AssertionError
I'm running tests with mocha and chai. res.body.data is an object array.
Read more >Developers - expect(array).to.deep.include({...}) does not apply deep ...
As the title says, if I run expect(array).to.deep.include(obj) I would expect to apply deep equality to each of the property of obj ....
Read more >Deep Equality with Pester - Medium
The Recursive Step is when we encounter a complex type and need to call our function on each item within the array or...
Read more >Testing JS & JSON Objects, Arrays, Object Arrays, Nested ...
When using this approach, rather than having referential equality ( a === b ), it will check an object's keys recursively until it...
Read more >5 Different Ways to Deep Compare JavaScript Objects
Object comparison in JavaScript is not as easy as comparing primitive data types. This article showcases five ways to deep compare JS ...
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
This fails with assert on chai v4.1.0:
expect([ { id: 1, name: 'first'}, { id: 2, name: 'second'}]).to.deep.include({ name: 'first' })
This is bug? How i can test if array include object with some specified properties?
upd: can be fixed with chai-subset plugin. Code is something like:
expect([ { id: 1, name: 'first'}, { id: 2, name: 'second'}]).to.containSubset([{ name: 'first' }])
@deksden
chai-subset
plugin is what I was looking for 👍