assert.notPropEqual()
追加されたバージョン: 1.11.0.
説明
notPropEqual( actual, expected, message = "" )
オブジェクト独自のプロパティを、厳格な不一致の比較を使用して比較します。
名前 | 説明 |
---|---|
actual |
テストされている式 |
expected |
既知の比較値 |
message (文字列) |
簡潔な説明 |
notPropEqual
アサーションは、厳密な不一致演算子 (!==
) を使用して、オブジェクトの独自のプロパティのみを比較します。
値が異なるプロパティ、余分なプロパティ、または欠落したプロパティがある場合、テストは合格します。
関連項目
assert.notPropContains()
を使用して、一部のプロパティが存在しないか不一致があるかどうかのみを確認します。assert.propEqual()
を使用して、代わりにプロパティが等しいかどうかをテストします。
例
2 つのオブジェクトのプロパティの値を比較します。
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
});
});