-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Immutable.js equality #3574
Comments
@philipp-spiess I guess we can add custom matchers like
I guess we can have extensions to |
What about creating a node module supporting that first? As soon as it gets stable enough we could merge it into Jest |
While working on custom matchers to solve jestjs#3574, I found out that the cause for not seeing this issue in `expect().toEqual()` comes from the fact that this matcher passes the `iterableEquality` to the `equals()` function. When I added this to the equal calls for our spy matchers as well, Immutable.js types were properly suppored. I'm considering this is a bug since the `toBeCalledWith()` matchers should behave the same as the `equals()` matcher.
While working on custom matchers to solve jestjs#3574, I found out that the cause for not seeing this issue in `expect().toEqual()` comes from the fact that this matcher passes the `iterableEquality` to the `equals()` function. When I added this to the equal calls for our spy matchers as well, Immutable.js types were properly suppored. I'm considering this is a bug since the `toBeCalledWith()` matchers should behave the same as the `equals()` matcher.
There is already this project: https://github.com/unindented/custom-immutable-matchers It could be just extended with |
While working on custom matchers to solve jestjs#3574, I found out that the cause for not seeing this issue in `expect().toEqual()` comes from the fact that this matcher passes the `iterableEquality` to the `equals()` function. When I added this to the equal calls for our spy matchers as well, Immutable.js types were properly suppored. I'm considering this is a bug since the `toBeCalledWith()` matchers should behave the same as the `equals()` matcher.
While working on custom matchers to solve jestjs#3574, I found out that the cause for not seeing this issue in `expect().toEqual()` comes from the fact that this matcher passes the `iterableEquality` to the `equals()` function. When I added this to the equal calls for our spy matchers as well, Immutable.js types were properly suppored. I'm considering this is a bug since the `toBeCalledWith()` matchers should behave the same as the `equals()` matcher.
* Use iterableEquality in spy matchers While working on custom matchers to solve #3574, I found out that the cause for not seeing this issue in `expect().toEqual()` comes from the fact that this matcher passes the `iterableEquality` to the `equals()` function. When I added this to the equal calls for our spy matchers as well, Immutable.js types were properly suppored. I'm considering this is a bug since the `toBeCalledWith()` matchers should behave the same as the `equals()` matcher. * Add spy matchers tests using ES6 Map and Set
* Use iterableEquality in spy matchers While working on custom matchers to solve jestjs#3574, I found out that the cause for not seeing this issue in `expect().toEqual()` comes from the fact that this matcher passes the `iterableEquality` to the `equals()` function. When I added this to the equal calls for our spy matchers as well, Immutable.js types were properly suppored. I'm considering this is a bug since the `toBeCalledWith()` matchers should behave the same as the `equals()` matcher. * Add spy matchers tests using ES6 Map and Set
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. |
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
The following test will unexpectedly fail because Immutable.js sometimes creates a new reference, although the value is the same. Look at this test for example:
Although
directlyCreated
andindirectlyCreated
have the same content and are treated the same by Immutable.js, the reference of the objects differ since one is created directly and another one is created by modifying an empty map. This errors with a very strange message:What is the expected behavior?
Our matches should be aware of Immutable.js objects and use
Immutable.is
orxyz#equals()
in that case.Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
This happens in the current master version and happens because the
eq
method taken from jasmine does not supportImmutable.is
for comparison. Now that we control those matchers, we might add support for that.If this is something we want to support, I'd love to work on it!
Edit: I run into this a lot and whenever I do, I have to use
fn.mock.calls[0][0]
to do the comparison, which, when using thetoEqual
matcher, strangely works.Edit2: Can it be that the matchers for
toHaveBeenCalledWith
compare the array of arguments usingequals()
and since this is a regular type, it uses a different code path then, whenequals()
is called with the Immutable.js type directly?The text was updated successfully, but these errors were encountered: