Back to Qunit

assert.notPropEqual()

docs/api/assert/notPropEqual.md

2.25.01.2 KB
Original Source

notPropEqual( actual, expected, message = "" )

Compare an object's own properties using a strict inequality comparison.

namedescription
actualExpression being tested
expectedKnown comparison value
message (string)Short description

The notPropEqual assertion compares only an object's own properties, using the strict inequality operator (!==).

The test passes if there are properties with different values, or extra properties, or missing properties.

See also

Examples

Compare the values of two objects properties.

js
QUnit.test('example', function (assert) {
  class Foo {
    constructor () {
      this.x = '1';
      this.y = 2;
    }

    walk () {}
    run () {}
  }

  const foo = new Foo();

  // succeeds, only own property values are compared (using strict equality),
  // and property "x" is indeed not equal (string instead of number).
  assert.notPropEqual(foo, {
    x: 1,
    y: 2
  });
});