jest-matcher-deep-close-to
jest-matcher-deep-close-to copied to clipboard
Allow comparison of functions
The test currently fails if a function type is encountered in the nested object. This can become troublesome when we're comparing objects that contain class instances with those instances containing function definitions as well.
Can we add logic to compare functions using strict equality? I could create a PR for this if needed.
Hello, how will you compare functions? It really feels out of the scope of this project. Maybe if you share an example I could understand more your needs
Hey, thanks for getting back.
Comparison of functions becomes an issue when dealing with class instances. In the screenshots below, you can see that the test fails when using toBeDeepCloseTo but passes when using toEqual.
Jest uses strict equality while comparing functions, and I think this library should too.
I have already made the necessary changes, please let me know if you want me to create a PR.
The problem in a class is that you will compare all the properties or only the numeric ones? As my concern the idea of this package is to extend the toBeCloseTo
matcher, that's why I think that if you have a class with 2 properties to be compared to is better to manually compare them.
If you still think that this changes belongs to this repo, you can create a PR and we discuss how to make it work for all of us.
I have created a PR #38