Open JimBarrows opened 7 years ago
@JimBarrows It doesn't look like chai-things supports what you're trying to do. The all
flag is for testing that each element in the target array passes a given assertion. For example:
[4, 11, 15].should.all.be.below(20); // Tests that each element in the array is below 20.
The good news is that in the upcoming Chai v4, the members
assertion supports the deep
flag. So you can accomplish your goal with just base Chai. It's available right now on npm as chai@4.0.0-canary.1
if you want to give it a shot.
Here's how it'd look with base Chai v4:
expect([{
__v: 0,
name: 'First one',
owner: "582a4aac593bdac822a535b6",
_id: "582a4aad593bdac822a535b7",
size: 0,
cards: []
},
{
__v: 0,
name: 'SecondOne',
owner: "582a4aac593bdac822a535b6",
_id: "582a4aad593bdac822a535b8",
size: 0,
cards: []
}
]).to.have.deep.members([
{
_id: '582a4aad593bdac822a535b7',
name: 'First one',
owner: '582a4aac593bdac822a535b6',
__v: 0,
size: 0,
cards: []
},
{
_id: '582a4aad593bdac822a535b8',
name: 'SecondOne',
owner: '582a4aac593bdac822a535b6',
__v: 0,
size: 0,
cards: []
}
]);
I was expecting this to return true. The only difference I can see is that the fields are in a different order. Is there something I'm missing?