jest-codemods
jest-codemods copied to clipboard
Add aliases for [email protected] in the transformer
Hi,
It would be nice to take into account the aliases for every functions that are map in the transformer for Expect.
Ex: https://github.com/mjackson/expect#toinclude
I don't know if there would be some collision problems because of the same function name present but with different behavior.
Hi @Justkant
Thanks for reporting this. I thought we already did this... Do you have a specific case that is not transformed?
Yes maybe it's really special but we were using the old toContain alias of toInclude (link) with an object as parameter and I think that we should use the new toContainEqual (link) for this case.
@Justkant thanks. So toContain should already be supported...
Did you get an error after using jest-codemods?
Hi @skovhus
Yes but toContain in some cases cannot be used as the old one.
Expect was using the isEqual module for toContain and so it was doing a deep equality check on objects and arrays.
This is not the case anymore, the new toContain is doing a strict equality check.
I think that we should use toContainEqual in those situations.
@Justkant is this not relevant anymore? Else let us keep it open. : )
Oh yes, my bad.
We used jest-codemods to update our tests. Because some of them were using toContain (the old alias) we had to manually edit them.
And so now we don't need really the support for those aliases but you're right that it could be useful to other people.
Thanks for your work on this.
Sure. I'm happy it was useful to you! : )
Let me know if you find other issues or have ideas for improving the codemod.