assert.notPropEqual()

添加版本:1.11.0.

描述

notPropEqual( actual, expected, message = "" )

使用严格不等比较来比较对象的自身属性。

名称 描述
实际 正在测试的表达式
预期 已知的比较值
message (字符串) 简短描述

notPropEqual 断言仅比较对象的自身属性,使用严格不等运算符 (!==)。

如果存在具有不同值的属性、额外的属性或缺少的属性,则测试通过。

另请参阅

示例

比较两个对象的属性值。

QUnit.test('example', 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
  });
});