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

feature: expect.toMatchObject #177

Open
vinicius73 opened this issue Dec 15, 2021 · 2 comments
Open

feature: expect.toMatchObject #177

vinicius73 opened this issue Dec 15, 2021 · 2 comments

Comments

@vinicius73
Copy link

Sometimes we just want check if a object is partially equal to another object.
In jest we have expect.toMatchObject

This is very useful when you must check a object with the certain dynamics values.
An example of that is when you call a API to create a resource, commonly, we do not know what is the values of id and fields like created_at and updated_at.

There already is a way to do it with uvu?
If not, there is any plan?

@hanayashiki
Copy link

@lukeed
Copy link
Owner

lukeed commented Dec 22, 2021

No, the expect.toMatchObject is a partial match. uvu already includes assert.equal which is a deep, equality check for exactness. Here's the difference:

let full = {
  name: 'lukeed',
  human: true,
}

assert.equal({ human: true }, full); // => throws error
assert.match({ human: true }, full); //=> OK, partial match

If this were to land, it'd be part of the assert.match helper, as shown, since that is uvu's "partial / wilcard matcher" helper.

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

No branches or pull requests

3 participants