jest-extended
jest-extended copied to clipboard
toIncludeSameMembers Does not seems to work with nested array
Here's a sample query:
expect(
await this.db.getSetsMembers(['test', 'test1']),
).toIncludeSameMembers([
['1234', '5678', 'abcd'],
['5678', 'abcd'],
])
But
Error: expect(received).toIncludeSameMembers(expected)
Expected list to have the following members and no more:
[["1234", "5678", "abcd"], ["5678", "abcd"]]
Received:
[["abcd", "5678", "1234"], ["abcd", "5678"]]
at HashSetTest.toIncludeSameMembers [as test set] (C:\Users\steve\typescript\nodebb-db-backend-typeorm\test\set.test.ts:23:7)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
They are both correct results but different in order.
Here's a workaround:
expect(await this.db.getSetsMembers(['test', 'test1'])).toSatisfy((arr) =>
_.isMatch(arr, [
['1234', '5678', 'abcd'],
['5678', 'abcd'],
]),
)
But this requires lodash