Chai: Failed assert.equal({},{})

Created on 2 Oct 2014  路  4Comments  路  Source: chaijs/chai

I try to check that function return an empty object. I can not use asser equal for that:

assert.equal({},{},"Can not compare empty objects"); 

Is that bug or feature?
Thanks,
Libor

Most helpful comment

@charlierudolph I overlook that sometimes too!
@liborbus assert.deepEqual is exactly what your looking for.

Cheers!

All 4 comments

.equal uses strict equality (===). This works for numbers, strings, booleans
http://chaijs.com/api/bdd/#equal-section

For comparisons of arrays and objects use .eql which will enumerate through and check that the contained objects are equal
http://chaijs.com/api/bdd/#eql-section

I understood that strict equality (===) is done by strictEqual while equal is non-strict equal (==). It is not much comfortable mix assert and bdd packages in the test. Anyway, maybe I found solution using deepEqual for comparing objects.

True. Sorry I always use the expect syntax. Forgot assert has different names. The non strict equal matcher isn't available on the expect syntax (which I like).

@charlierudolph I overlook that sometimes too!
@liborbus assert.deepEqual is exactly what your looking for.

Cheers!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AnAppAMonth picture AnAppAMonth  路  3Comments

xareelee picture xareelee  路  3Comments

danthegoodman picture danthegoodman  路  3Comments

kharandziuk picture kharandziuk  路  4Comments

qbolec picture qbolec  路  5Comments