I'm using chai.js
expectations with the mocha JS test framework. I'm trying to test inclusion of objects in arrays but it appears the includes
behavior supported by chai in their documentation doesn't work as I expect:
The example on the chai website says this:
expect({a: 1, b: 2, c: 3}).to.include({a: 1, b: 2});
That works as expected. However, the following fails:
expect([{a: 1}]).to.be.an('array').and.include({a: 1})
with the error:
(node:5639) ... AssertionError: expected [ { a: 1 } ] to include { a: 1 }
But this succeeds:
expect([1,2]).to.be.an('array').and.include(1)
What am I doing wrong?