jest-codemods icon indicating copy to clipboard operation
jest-codemods copied to clipboard

Chai's `to.deep.have.members` is converted to `toEqual` which is wrong

Open deser opened this issue 7 years ago • 4 comments

I have found correct method for that in jest-extended - toIncludeAllMembers.

deser avatar Aug 02 '18 10:08 deser

Thanks for reporting this. Are you up for creating a PR for this? We don't want to depend on jest-extended though.

skovhus avatar Aug 02 '18 10:08 skovhus

Not sure I see alternative to toIncludeAllMembers

deser avatar Aug 02 '18 10:08 deser

So I just checked and we convert:

- expect([{ id: 1 }]).to.deep.include.members([{ id: 1 }]);
+ expect([{ id: 1 }]).toEqual(expect.arrayContaining([{ id: 1 }]));

That seems to be correct. Can you report which case this didn't work for you @deser

skovhus avatar Sep 18 '18 18:09 skovhus

As far as I remember it was just toEqual without expect.arrayContaining. However I'm not sure that to.deep.include.members is covered by toEqual(expect.arrayContaining, you can check what's inside toIncludeAllMembers I just don't have time to cover all cases

deser avatar Sep 19 '18 08:09 deser