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

fix: make Errors match with ordinary objects (fixes #5359) #5611

Merged
merged 3 commits into from
Feb 19, 2018
Merged

fix: make Errors match with ordinary objects (fixes #5359) #5611

merged 3 commits into from
Feb 19, 2018

Conversation

kpsroka
Copy link
Contributor

@kpsroka kpsroka commented Feb 19, 2018

Summary

Fixes #5359 -- makes toMatchObject work when comparing Errors with ordinary objects. This is accomplished by extending subset matching algorithm to include prototype properties of the object under test.

Test plan

Added two test cases in matchers.test.js. No other tests were modified.
However, yarn test fails with the following error:

  ● exceeds the timeout

    expect(received).toMatch(expected)
    
    Expected value to match:
      /(jest\.setTimeout|jasmine\.DEFAULT_TIMEOUT_INTERVAL|Exceeded timeout)/
    Received:
      "PASS __tests__/a-banana.js
      ✓ banana
    
    "

Bonkers. Let's see if CI catches that one too.

@codecov-io
Copy link

codecov-io commented Feb 19, 2018

Codecov Report

Merging #5611 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #5611   +/-   ##
=======================================
  Coverage   60.63%   60.63%           
=======================================
  Files         213      213           
  Lines        7311     7311           
  Branches        4        4           
=======================================
  Hits         4433     4433           
  Misses       2877     2877           
  Partials        1        1

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0b88438...f0b2505. Read the comment docs.

Copy link
Collaborator

@thymikee thymikee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

@thymikee thymikee requested a review from SimenB February 19, 2018 14:56
@cpojer cpojer merged commit f5879c0 into jestjs:master Feb 19, 2018
@cpojer
Copy link
Member

cpojer commented Feb 19, 2018

Thanks for submitting a PR to Jest!

@@ -2,6 +2,8 @@

### Fixes

* `[enzyme]` Allow matching of Errors against plain objects
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not enzyme, wrong matcher library :D

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, nice!

@github-actions
Copy link

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

Successfully merging this pull request may close these issues.

toMatchObject not working to assert on the message of an error
6 participants