QUnit API Documentation

deepEqual()


Categories: Assert

deepEqual( actual, expected, message )

Description: A deep recursive comparison assertion, working on primitive types, arrays, objects, regular expressions, dates and functions.

  • deepEqual( actual, expected, message )

    • actual
      Type: Object
      Object or Expression being tested
    • expected
      Type: Object
      Known comparison value
    • message
      Type: String
      A short description of the assertion

The deepEqual() assertion can be used just like equal() when comparing the value of objects, such that { key: value } is equal to { key: value }. For non-scalar values, identity will be disregarded by deepEqual.

notDeepEqual() can be used to explicitly test deep, strict inequality.

Example:

Compare the value of two objects.

1
2
3
4
5
test( "deepEqual test", function() {
var obj = { foo: "bar" };
deepEqual( obj, { foo: "bar" }, "Two objects can be the same in value" );
});
gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.