I'm writing tests to validate what an async process has written to mongo and I'm having issues with should.include to verify that a record is included. To simplify it, my projection only includes a single field (ag_status) and I receive the following error from should:
1) Agriculture record should return at least one record with ag_status to true:
Uncaught AssertionError: expected [ { ag_status: true },
{ ag_status: true },
{ ag_status: true },
{ ag_status: true },
{ ag_status: true },
{ ag_status: true } ] to include an object equal to { ag_status: true }
Here is the section of code that calls the should.include. I have tried chai, chai-fuzzy and chai-things, but none of them have worked (and do not give as detailed messages as should) so I am stuck right now. Any help is greatly appreciated.
it('Agriculture record should return at least one record with ag_status to true', function(done){
MobAgriculture.model.find({ time_id: "AYearAgo" }, {_id: 0, ag_status: 1 }, function(err, result) {
should.not.exist(err);
should.exist(result);
result.should.have.length(6);
console.log(result);
var level2 = { "ag_status" : true };
result.should.include(level2);
done();
});
});