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

Add aliases for [email protected] in the transformer

Open Justkant opened this issue 8 years ago • 7 comments

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.

Justkant avatar Sep 05 '17 16:09 Justkant

Hi @Justkant

Thanks for reporting this. I thought we already did this... Do you have a specific case that is not transformed?

skovhus avatar Sep 05 '17 20:09 skovhus

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 avatar Sep 06 '17 09:09 Justkant

@Justkant thanks. So toContain should already be supported...

Did you get an error after using jest-codemods?

skovhus avatar Sep 10 '17 17:09 skovhus

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 avatar Sep 11 '17 13:09 Justkant

@Justkant is this not relevant anymore? Else let us keep it open. : )

skovhus avatar Sep 21 '17 08:09 skovhus

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.

Justkant avatar Sep 21 '17 13:09 Justkant

Sure. I'm happy it was useful to you! : )

Let me know if you find other issues or have ideas for improving the codemod.

skovhus avatar Sep 21 '17 15:09 skovhus