| layout | page-api | ||
|---|---|---|---|
| title | assert.notPropEqual() | ||
| excerpt | Compare an object's own properties for inequality. | ||
| groups |
|
||
| redirect_from |
|
||
| version_added | 1.11.0 |
notPropEqual( actual, expected, message = "" )
Compare an object's own properties using a strict inequality comparison.
| name | description |
|---|---|
actual |
Expression being tested |
expected |
Known 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.
- Use
assert.notPropContains()to only check for the absence or inequality of some properties. - Use
assert.propEqual()to test for equality of properties instead.
Compare the values of two objects properties.
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
});
});