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

Asymmetric matches should be formatted #2215

Closed
just-boris opened this issue Dec 4, 2016 · 2 comments
Closed

Asymmetric matches should be formatted #2215

just-boris opened this issue Dec 4, 2016 · 2 comments

Comments

@just-boris
Copy link
Contributor

What is the current behavior?

Jasmine gives you special values that you can use at the right side of toEqual, to make the comparison more flexible. After #2213 this also will be landed as a part of Jest API.
However, there is a problem with error message formatting. Given the following assertion:

expect({
  a: 1,
  b: {
    test: false
  }
}).toEqual({
  a: 1,
  b: jasmine.objectContaining({
    test: true
  })
})

Produces the following error message:

Expected value to equal:
      {"a": 1, "b": {"sample": {"test": true}}}
    Received:
      {"a": 1, "b": {"test": false}}

What is the expected behavior?

I expect to have printed special format for asymmetric comparison value.
For example, pure Jasmine detects special value and formats it accordingly:

Expected 
  Object({ a: 1, b: Object({ test: false }) }) 
to equal 
   Object({ a: 1, b: <jasmine.objectContaining(Object({ test: true }))> }).

It would be nice to do this in Jest as well. It also worth to mention that all asymmetric values have a special method .jasmineToString that gives pretty-printed value for message.

@thymikee
Copy link
Collaborator

We're actively working on this here: #2397. Feel free to join the discussion. Closing the issue.

@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 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants