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

Fixed object matcher #3799

Merged
merged 1 commit into from
Jun 12, 2017
Merged

Conversation

jzeiders
Copy link
Contributor

Summary

Updated the object matcher utility to use hasOwnProperty independent of the object passed.
Before, expect(Object.create(null)).toMatchObject(someObject) would throw an error, as Object.create(null) lacks the object prototype.

It appears that you all had already noticed this as you had created a helper for it, but weren't actually using it.

Test plan

yarn run jest --silent && yarn run test-examples --silent

screen shot 2017-06-12 at 12 18 08 pm

screen shot 2017-06-12 at 12 17 56 pm

@@ -79,7 +79,7 @@ const getObjectSubset = (object: Object, subset: Object) => {
) {
const trimmed = {};
Object.keys(subset)
.filter(key => object.hasOwnProperty(key))
.filter(key => hasOwnProperty(object, key))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Must have missed that, thanks!

@cpojer cpojer merged commit 7ac4899 into jestjs:master Jun 12, 2017
@codecov-io
Copy link

Codecov Report

Merging #3799 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3799   +/-   ##
=======================================
  Coverage   57.58%   57.58%           
=======================================
  Files         194      194           
  Lines        6776     6776           
  Branches        6        6           
=======================================
  Hits         3902     3902           
  Misses       2871     2871           
  Partials        3        3
Impacted Files Coverage Δ
packages/jest-matchers/src/utils.js 100% <100%> (ø) ⬆️

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 03bb9b3...bd41748. Read the comment docs.

tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
@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 13, 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.

5 participants