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

Implement toIncludeAllPartialMembers #210

Merged
merged 5 commits into from
Oct 11, 2021

Conversation

ibarsi
Copy link
Contributor

@ibarsi ibarsi commented Mar 31, 2019

What

Implement toIncludeAllPartialMembers matcher.

Why

Consider the following test:

test('passes when given array values match the partial members of the set', () => {
  expect([{ foo: 'bar', baz: 'qux' }]).toIncludeAllMembers([{ foo: 'bar' }]);
});

I would like to assert that the provided array's objects partially contain all properties of the provided members. Currently, toIncludeAllMembers is the closest available matcher but it's too strict on matching the exact shape of each member.

What I need is the matcher to ignore additional properties and only partially match against the provided members.

Notes

  • As an alternative to a net new matcher, we could extend toIncludeAllMembers to accept an options object (e.g. { isPartial: true }) that would configure the matcher to either partially or fully test for equality.
  • toIncludeAnyPartialMembers would be another potentially useful matcher, but I wanted to keep this PR small and focused.

Housekeeping

  • Unit tests
  • Documentation is up to date
  • No additional lint warnings
  • Add yourself to contributors list (yarn contributor)
  • Typescript definitions are added/updated where relevant

@codecov-io
Copy link

codecov-io commented Mar 31, 2019

Codecov Report

Merging #210 (c1fc115) into main (adb82b8) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #210   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          123       125    +2     
  Lines          761       774   +13     
  Branches       111       115    +4     
=========================================
+ Hits           761       774   +13     
Impacted Files Coverage Δ
src/matchers/index.js 100.00% <100.00%> (ø)
src/matchers/toIncludeAllPartialMembers/index.js 100.00% <100.00%> (ø)
...c/matchers/toIncludeAllPartialMembers/predicate.js 100.00% <100.00%> (ø)

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 adb82b8...c1fc115. Read the comment docs.

@ibarsi
Copy link
Contributor Author

ibarsi commented Apr 28, 2019

Bump, curious if anyone’s had the chance to look into this yet? 🙂

@ispyinternet
Copy link

I would like this.

@ibarsi ibarsi force-pushed the igor/to-incude-all-partial-members branch from e3b21e5 to 3a046a9 Compare July 3, 2019 20:18
@jadbox
Copy link

jadbox commented Jul 18, 2019

@ibarsi Pretty please add toIncludeAnyPartialMembers to this PR... it would resolve this old request of mine: #146

@mooseburgr
Copy link

Bumping this as well. Any concerns with adding and releasing this? (Besides the request to throw in a toIncludeAnyPartialMembers on PR as well.)

@jbjhjm
Copy link

jbjhjm commented Mar 10, 2021

Bump, this is a useful new piece for jest-extended and I'm sad to see the pull request is waiting for almost 2 years now!

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

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

thanks!

@SimenB SimenB changed the title ✨ Implement toIncludeAllPartialMembers Implement toIncludeAllPartialMembers Oct 11, 2021
@SimenB SimenB merged commit 32afe6f into jest-community:main Oct 11, 2021
@ibarsi ibarsi deleted the igor/to-incude-all-partial-members branch October 25, 2021 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants