Created
November 29, 2018 09:54
-
-
Save mbjelac/d4a549446a15ab3dd926d606b7be9ba2 to your computer and use it in GitHub Desktop.
Jest toEqual failure report with undefined properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const a = { foo: undefined, bar: 1 }; | |
const b = { bar: 2 }; | |
test('toEqual wrongly reports undefined properties', () => { | |
expect(a).toEqual(b); | |
}); | |
test('toStrictEqual wrongly reports undefined properties', () => { | |
expect(a).toStrictEqual(b); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
both of these tests correctly fail. the problem is in the failure report:
the report should have
"foo": undefined
in neither section because that property is equal to the other object's (since not setting a property and setting it toundefined
is the same thing).