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

toMatchObject throws TypeError when a source property is null #6313

Merged
merged 4 commits into from
May 27, 2018

Conversation

WillBrock
Copy link
Contributor

Summary

This fixes the issue brought up in #6235

test.only("foo", () => {
  expect({ foo: null }).toMatchObject({ foo: { bar: "baz" } });
});

This code above gives a TypeError as opposed to a nice assertion error.

Test plan

Added a few tests for the subsetEqulity function.

I've signed the CLA.

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@@ -206,6 +206,8 @@ export const subsetEquality = (object: Object, subset: Object) => {

return Object.keys(subset).every(
key =>
object !== null &&
Copy link
Member

Choose a reason for hiding this comment

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

can do just object != null for both at once

CHANGELOG.md Outdated
@@ -7,6 +7,7 @@

### Fixes

* `[expect]` toMatchObject throws TypeError when a source property is null ([#6313](https://github.com/facebook/jest/pull/6313))
Copy link
Member

Choose a reason for hiding this comment

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

If you rebase, this should go under master (23.0.1 has been released)

@codecov-io
Copy link

codecov-io commented May 27, 2018

Codecov Report

Merging #6313 into master will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6313      +/-   ##
==========================================
+ Coverage   63.65%   63.67%   +0.02%     
==========================================
  Files         227      226       -1     
  Lines        8637     8634       -3     
  Branches        3        3              
==========================================
  Hits         5498     5498              
+ Misses       3138     3135       -3     
  Partials        1        1
Impacted Files Coverage Δ
...ircus/src/legacy_code_todo_rewrite/jest_adapter.js 0% <0%> (ø) ⬆️
packages/jest-runner/src/run_test.js 5.08% <0%> (ø) ⬆️
packages/jest-circus/runner.js

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 266e7dc...0b90e2c. Read the comment docs.

@thymikee
Copy link
Collaborator

Mind rebasing/merging master?

@WillBrock
Copy link
Contributor Author

Done.

@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.

None yet

5 participants