toEqual doesn't do deep equal
See original GitHub issue🐛 Bug Report
toEqual
doesn’t do deep equal
To Reproduce
just run:
expect({
target: {
value: 'a',
nodeType: 1
}
}).toEqual({
target: {
value: 'asd sad asd ad asdasdasd asdasdsa',
nodeType: 1
}
});
Test will pass
Expected behavior
Test shoudn’t pass
Link to repl or repo (highly encouraged)
https://github.com/bondom/jest-bug
Run npx envinfo --preset jest
Paste the results here:
System:
OS: macOS High Sierra 10.13.4
CPU: x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Binaries:
Node: 8.10.0 - /usr/local/bin/node
npm: 6.0.1 - /usr/local/bin/npm
npmPackages:
jest: ^22.4.4 => 22.4.4
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Jest toEqual is failing and I don't know why - Stack Overflow
Ok. As it seems, it's a Windows/ Git issue. This is the text with JSON.stringify console.log "type Query {\n updateTest(input: UpdateOne!):
Read more >Why you should never use .toBe in Jest - DEV Community
toEqual works based on deep equality .toBe is literally just doing a Object.is(x, y) under the hood. Which is slightly different, ...
Read more >The hidden power of Jest matchers | by Boris - Medium
toEqual(fooOrBar); // fails, not either 'foo' or 'bar' ... This will not work because functions are not equal to each other.
Read more >Expect - Jest
This is a deep-equality function that will return true if two objects have ... You can use it inside toEqual or toBeCalledWith instead...
Read more >Equality comparisons and sameness - JavaScript | MDN
Triple equals ( === ) will do the same comparison as double equals (including the special handling for NaN , -0 , and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
How about documenting this speciality behaviour? There’s nothing in the paragraph about toEqual. What could be worse than an unreliable test framework?
@yeahio this bug has been fixed, and I’ve just tried it out and confirmed that it still is fixed