-
Notifications
You must be signed in to change notification settings - Fork 0
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
Deep-equals fails on collection elements #20
Comments
Looking into this, I actually found that my understanding was mistaken. This test passes: expect(collection[0]).toEqual({foo: "bar"}); This test fails: expect(collection).toEqual([{foo: "bar"}]); The problem is that |
To make this slightly more complicated... You can't assign to const collection = [{foo: "bar"}];
collection.index(); The let collection = [{foo: "bar"}];
collection = collection.index(); This isn't necessarily ideal as it changes out API, but it's also not that bad. My favorite short-hand would still work: const collection = [{foo: "bar"}].index(); What may be a better option is to detach the Either way, there's some real thought that needs to be put into this |
Alternate idea: What if I just add a const collection = [{foo: "bar"}].index();
expect(collection.toArray()).toEqual([{foo: "bar"}]); I thought about this after re-reading my README and seeing this section:
Even if we could wrap the collection in a |
If we find a way to solve this without adding a |
When writing unit tests, the following fails:
The error returned says there are no "visual differences", but the values are different. This is likely because the collection element is a
Proxy
and I'm comparing it to anObject
.It may be possible to modify the Proxy in some way that this equality succeeds. It may be a matter of returning
Object
when they try to callget(obj, "__proto__")
, or I may have to modifygetOwnPropertyDescriptor
or something. To be frank, I don't know what needs to be done (or if it's possible) -- but I'll look into this.The text was updated successfully, but these errors were encountered: