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

Error message when comparing Immutable-js collection to array is confusing #2489

Closed
Daniel15 opened this issue Jan 2, 2017 · 5 comments · Fixed by #2899
Closed

Error message when comparing Immutable-js collection to array is confusing #2489

Daniel15 opened this issue Jan 2, 2017 · 5 comments · Fixed by #2899

Comments

@Daniel15
Copy link
Contributor

Daniel15 commented Jan 2, 2017

Do you want to request a feature or report a bug?
Enhancement request (so feature, I guess?)

What is the current behavior?
Given a test like this:

const Immutable = require('immutable');
it('compares Immutable-js collections', () => {
  expect(Immutable.OrderedSet(['foo'])).toEqual(['foo']);
});

The failure message is a bit confusing:

 FAIL  html/js/ads/utils/__tests__/SomeTest-test.js
  â— compares Immutable-js collections

    expect(received).toEqual(expected)

    Expected value to equal:
      ["foo"]
    Received:
      ["foo"]

    Difference:

    Comparing two different types of values:
      Expected: array
      Received: object

      at Object.<anonymous> (html/js/ads/utils/__tests__/SomeTest-test.js:38:50)
      at process._tickCallback (internal/process/next_tick.js:103:7)

What is the expected behavior?
Maybe something like this:

    Comparing two different types of values:
      Expected: array
      Received: Immutable.OrderedSet

Or this:

    Expected value to equal:
      ["foo"]
    Received:
      Immutable.OrderedSet("foo")

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
Whichever version of Jest we use internally at Facebook.

@thymikee
Copy link
Collaborator

thymikee commented Jan 2, 2017

We could definitely create a pretty-format plugin for that

@ttmarek
Copy link
Contributor

ttmarek commented Feb 10, 2017

@thymikee I can give this a shot if no one else will. I'd like to contribute more to the Jest ecosystem...and this seems like a small enough issue to start off with. I might even have some time this weekend. Any tips on where to start are welcome 🙂

@thymikee
Copy link
Collaborator

@ttmarek great! Of course you can take it.

For the Jest part you can start with looking at how to write a plugin for pretty-format package and how to detect that the value passed to it is coming from Immutable library.
Then you'll need to update prettyFormat calls with plugins option in Jest codebase.

@cpojer
Copy link
Member

cpojer commented Mar 6, 2017

This will be in the next version of Jest thanks to @cpenarrieta.

@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants