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.

Add a way to do shallow equal

See original GitHub issue

Possible names for a shallow eq validator:

  • toShallowEqual
  • toBe (jest style)

Personally I like toShallowEqual - it also goes well with toLooseEqual that we already have.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
krzkaczorcommented, Dec 10, 2020

As per discussion with @sz-piotr I decided to rename it to toStrictlyEqual.

IMO toBe is too short it looks like it’s incentivizing by us to use but in reality, 95% of cases should be covered by toEqual. I will fix it and merge it later today.

1reaction
krzkaczorcommented, Dec 5, 2020

@sz-piotr So what you’re saying is that we shouldn’t allow (at least on a type system lvl) comparing primitive values with toBe, right?

It’s an interesting point… and I think you’re right. But! We can make a signature to be more like: toBe(value: T) and add condition that T extends object. This way we get type safety.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add a way to do shallow equal · Issue #87 · dethcrypto/earl
Another alternative is toStrictlyEqual which is clearer than toShallowEqual but I still prefer toBe as I'm testing for identity, not some kind ...
Read more >
shallow-equal - npm
Minimalistic shallow equality check for arrays/objects. ... Start using shallow-equal in your project by running `npm i shallow-equal`.
Read more >
How can I do a shallow comparison of the properties of two ...
Returns true when the values of all keys are strictly equal. ... To do a "shallow" comparison where inherited properties should be ignored ......
Read more >
Shallow Compare - React
shallowCompare performs a shallow equality check on the current props and nextProps objects as well as the current state and nextState objects. It...
Read more >
wordpress/is-shallow-equal | Block Editor Handbook
A function for performing a shallow comparison between two objects or arrays. Two values have shallow equality when all of their members are...
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