-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[Docs]: .tocontainequalitem() explanation is ambiguous #15201
Comments
Still can't tell from context.
I tested it and Jest throws an error when the
myBeverages does contain myBeverage
expect(received).toContainEqual(expected) // deep equality
Expected value: {"delicious": true, "sour": false}
Received object: {"0": {"delicious": true, "sour": false}, "1": {"delicious": true, "salty": true, "sour": true}}
> 197 | ? expect(target).toContainEqual(subject) Also this is somewhat misleading as we are using the term 'deep equality' when comparing objects when 'deep equality' compares objects in the location in memory, not by comparing their ex. const obj1 = { pet: 'dog'}
const obj2 = { pet: 'dog'}
const obj3 = { pet: 'cat'}
console.log(obj1 === obj1) // true
console.log(obj1 === obj2) // false
console.log(obj1 === obj3) // false
Still not sure
No, it does not. It has to be exactly the same key: value pairs. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
1 similar comment
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Page(s)
https://github.com/jestjs/jest/blob/main/docs/ExpectAPI.md#tocontainequalitem
Description
I find this explanation is very ambiguous.
I have the following questions:
What does the
myBeverages()
return? An array, I think.So does the expect argument HAVE TO BE an array? I think so.
Does
myBeverage
have to be an object literal? Could it be an array inside an array? Not sure.Does myBeverage match to things which have more fields than the specified fields? Not sure.
The text was updated successfully, but these errors were encountered: