diff --git a/test/matchers/toIncludeSamePartialMembers.test.js b/test/matchers/toIncludeSamePartialMembers.test.js index e9ca18a3..8f3ab3ea 100644 --- a/test/matchers/toIncludeSamePartialMembers.test.js +++ b/test/matchers/toIncludeSamePartialMembers.test.js @@ -10,6 +10,13 @@ describe('.toIncludeSamePartialMembers', () => { ]); }); + test('passes when array values matches the partial members of the set in different order', () => { + expect([{ hello: 'world' }, { foo: 'bar', baz: 'qux' }]).toIncludeSamePartialMembers([ + { foo: 'bar' }, + { hello: 'world' }, + ]); + }); + test('fails when array values do not contain any of the members of the set', () => { expect(() => expect([{ hello: 'world' }, { foo: 'bar', baz: 'qux' }]).toIncludeSamePartialMembers([{ foo: 'qux' }]), diff --git a/types/index.d.ts b/types/index.d.ts index 9436c25c..4e56c6ff 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -502,6 +502,12 @@ declare namespace jest { */ toIncludeAllPartialMembers(members: readonly E[]): R; + /** + * Use `.toIncludeSamePartialMembers` when checking if an `Array` contains exactly the same partial members as a given set, in any order + * @param {Array.<*>} members + */ + toIncludeSamePartialMembers(members: readonly E[]): R; + /** * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set. * @param {Array.<*>} members