Giter Club home page Giter Club logo

Comments (4)

SimenB avatar SimenB commented on July 19, 2024

I think it makes sense to align, but I'll defer to @georgekaran

from jest.

georgekaran avatar georgekaran commented on July 19, 2024

Hey @stephenh

Your points make a lot of sense when it comes to the SERIALIZABLE_PROPERTIES. To be honest, maybe the name SERIALIZABLE_PROPERTIES wasn't the best choice 😅, which might have led to some confusion as it seems to imply a broader scope than it currently has.

That being said, I think we could go to either two directions:

  • Rename this property to make it clear that is only used by the diff printer;
  • Apply this same variable to equality checkers.

Personally the second option makes more sense to me, but is probably gonna take a lib bit more time than just a renaming.

Let me know what you guys think, so I can start working on a draft to address this issue and aim to include it in a future pull request.

from jest.

github-actions avatar github-actions commented on July 19, 2024

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days.

from jest.

Fryuni avatar Fryuni commented on July 19, 2024

It seems the misunderstanding was here:

The name SERIALIZABLE_PROPERTIES to me infers it will be used "for serialization" which I would have expected to apply to both "the toEqual check" as well as "the toEqual diff", but also

Specifically, the "toEqual check". There is no serialization there; what is being compared is the runtime values. If it weren't for that, many values that are supposed to be different would pass as equals and vice-versa.

For example, a sparse array of length 2 (Array(2)) has the same value in all positions as an array of two undefined elements ([,,]), but those two don't serialize to the same thing ([ <2 empty items> ] vs [undefined, undefined]). This even happens in other cases like objectContaining, where the two objects being compared can be of different classes and, as such, will serialize differently while matching the test. The diff might show all the lines that are different, even though only a few of them might actually be causing the matcher to fail.

If the matcher was .serializesEquallyAs(other), then it would make sense to serialize the value for comparison.

from jest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.