What matcher would I use in Jest to test for the absence of a property on an object.
My MUT returns an object, say {userName: 'Joe'}
.
How do I test that the object does NOT contain a property named password
?
Such that this result would fail the test: {userName: 'Joe', password: 'pwd'}
.
I've thought of .toBeUndefined()
, but if the password property is there, and just contains an undefined
value, the test would yield a false pass - such a case should fail, because the password
property is there (even though it's value is undefined
).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…