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

The deep equality algorithm does not work properly for complex objects #251

Open
justinenht opened this issue Sep 20, 2024 · 0 comments
Open

Comments

@justinenht
Copy link

  • library version : 8.0.2
  • Environment : Node 20
  • Example URL :
  • Other libraries you are using:

What did you expect to happen?

deepEqual should return false for different complex objects.

What actually happens

It returns true for two different complex objects. After some investigation, it is because the Object.keys() or Object.getOwnPropertySymbols return empty arrays:

var actualKeys = keys(actualObj);

How to reproduce

Clone the samsam repository, add in the following test in the ``deep-equal.test.js` file:

it("check URL", function () {
  var checkDeep = samsam.deepEqual(new URL('http://mock'), new URL('http://aaaaa'));
  assert.isTrue(checkDeep);
});

Run all the tests with npm run test and see that the test is passed, whereas it should have failed:
image

I have seen that the other fixes for the other deepEqual issues have been fixed with some special handling. Maybe it would be better to have a fail-safe mechanism to make the deepEqual return false when it is not possible to extract keys.properties from a complex object, instead of considering it as true ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant