question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
yeahiocommented, Feb 22, 2019

How about documenting this speciality behaviour? There’s nothing in the paragraph about toEqual. What could be worse than an unreliable test framework?

2reactions
jeysalcommented, Feb 22, 2019

@yeahio this bug has been fixed, and I’ve just tried it out and confirmed that it still is fixed

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found