i'm writing javascript unit tests (with qunit library). need verify array contains expected (and only) elements.
var array = getarrayfunction(a, b); equal(["one", "two", "three"], array, "test failing if 'array' contains needed elements");
what easiest way this?
you need use deepequal()
in lieu of equal()
. compare array elements , object properties, not use ==
comparison operator, evaluates false
objects don't share same constructor.
docs here: https://api.qunitjs.com/deepequal/
more information javascript equality comparison: https://developer.mozilla.org/en-us/docs/web/javascript/equality_comparisons_and_sameness
Comments
Post a Comment