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

Chai-should produced bad translation of chained property an

Open sirreal opened this issue 8 years ago • 3 comments

The chai-should codemod produces a bad result when chaining property with a/an. See this diff produced:

expect( state )
-  .to.have.property( 'example.wordpress.com' )
-  .to.be.a( 'object' );
+ .expect( typeof state ).toBe( 'object' );

See failing tests with proposed codemod result in #92

Detected in https://github.com/Automattic/wp-calypso/pull/19631 by @gziolo

sirreal avatar Nov 13 '17 11:11 sirreal

@sirreal thanks for reporting this! And thanks for the failing test.

skovhus avatar Nov 14 '17 08:11 skovhus

You bet! Thanks for your work on the codemods 😀

sirreal avatar Nov 14 '17 09:11 sirreal

Chaining is currently unsupported in the chai-should... But it should be possible to add, like we did in the expect codemod. : )

skovhus avatar Nov 19 '17 08:11 skovhus