question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Matcher for part of object properties

See original GitHub issue

It’d be cool to have a matcher for a subset of object properties. Eg.:

expect({a: 1, b: 2, c: 3}).toContainSubset({a: 1, c: 3})

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
krzkaczorcommented, Dec 15, 2020

@all-contributors please add @krzysztof-jelski for ideas

0reactions
sz-piotrcommented, Dec 5, 2020

I’d prefer something grammatically correct. So definitely toBeAContainerWith and toBeAnArrayWith over toBeContainerWith and toBeArrayWith. I’d also propose renaming toBeAContainerWith to toContain

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to check for object properties match for an object using ...
I want to write a test case that checks if the object has the tree property named accordingly and their value is number,...
Read more >
Jest Array/Object partial match with objectContaining and ...
It's possible to do partial matches on Arrays and Objects in Jest using expect. objectContaining and expect. arrayContaining .
Read more >
Matching Properties and Values in the Object challenge.
In this post let's make a function that looks through an array of objects (first argument) and returns an array of all objects...
Read more >
Matching Object Properties | Fabrication Products
The Match Object(s) Properties command allows the user to copy selected properties from one Item and paste them to other single or multiple ......
Read more >
Jest partial matching on objects, arrays and functions
We can do this using Jest's partial matchers. In this post I will cover: Using Jest's objectContaining to match on certain key/value pairs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found