jest-community/jest-extended

Better clarify the difference between toIncludeAllMembers and toIncludeSameMembers in the documentation

rdsedmundo opened this issue · 0 comments

Feature Request
Description:
Only by reading the names is not very straightforward to reason about the difference immediately, specially when the description of toIncludeAllMembers mentions the same members.

The difference as I understand is this:

expect([1, 2, 3]).toIncludeSameMembers([1, 2, 3]); // passes, as array elements are equal, extra elements are not allowed
expect([1, 2, 3, 4]).toIncludeAllMembers([1, 2, 3]); // passes, even though there's an extra 4, it also contains [1, 2, 3]

Possible solution:

  • Improve the description text, emphasizing that for toIncludeSameMembers no extra values are allowed.
  • Add negative test cases (e.g using .not) instead of just positive examples.