Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toEqual doesn't do deep equal #6204

Closed
bondom opened this issue May 18, 2018 · 6 comments · Fixed by #6246
Closed

toEqual doesn't do deep equal #6204

bondom opened this issue May 18, 2018 · 6 comments · Fixed by #6246

Comments

@bondom
Copy link

bondom commented May 18, 2018

🐛 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
@rickhanlonii
Copy link
Member

rickhanlonii commented May 18, 2018

@bondom thanks for the report - the issue here is that the nodeType field makes Jest think that this is a dom node (see here).

This, for example, will fail:

expect({
  target: {
    value: "a",
    type: 1
  }
}).toEqual({
  target: {
    value: "asd sad asd ad asdasdasd asdasdsa",
    type: 1
  }
});

@SimenB
Copy link
Member

SimenB commented May 18, 2018

Was just about to write the same thing.

Can we make isDomNode more robust?

@SimenB
Copy link
Member

SimenB commented May 18, 2018

@yeahio
Copy link

yeahio commented 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?

@jeysal
Copy link
Contributor

jeysal commented Feb 22, 2019

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

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants