jeudi 26 novembre 2015

Asserting object equality in Javascript test (chai)

I need to assert equality between two points in my JavaScript unit tests:

var pnt1 = {x: 2, y: 3};

and

var pnt2 = {x: 2, y: 3};

When I do

assert.equal(pnt1, pnt2);

It says the points are different. Can I exclude from the check the fact that the objects are different instances (so in fact they are "not equal")?

I'd like to avoid creating a list of assert, one for each field to test (in this case .x and .y)

Aucun commentaire:

Enregistrer un commentaire