skovhus / jest-codemods

Codemods for migrating to Jest https://github.com/facebook/jest 👾
MIT License
877 stars 81 forks source link

`jasmine-globals`: `argsFor` gets incorrectly transformed with certain parsers #585

Closed puglyfe closed 1 month ago

puglyfe commented 1 month ago

Reproduction https://astexplorer.net/#/gist/d0edcfa0efac245e5127767be88b3930/e9df7378995891f5c94ccd29a0a4f74072de4eb4

Example input

someSpy.calls.argsFor(0)[1]

Output for parsers: ['babel', 'flow']

someSpy.mock.calls[0][1] // ✅

Output for parsers: ['babylon', 'ts', 'tsx']

someSpy.mock.calls.0[1] // ❌ invalid syntax