skovhus / jest-codemods

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

`jasmine-globals`: async `SpyStrategy` methods are not supported #577

Closed puglyfe closed 3 months ago

puglyfe commented 3 months ago

👋 another one from me. async jasmine SpyStrategy methods (i.e. rejectWith and resolveTo) trigger Unsupported Jasmine functionality warnings (source). These have jest equivalents of mockResolvedValue(value) and mockRejectedValue(value).

Example input:

jasmine.createSpy().and.resolveTo('some value');

Actual output:

// Logs `Unsupported Jasmine functionality "jasmine.createSpy().and.resolveTo".` during transform
jest.fn().and.resolveTo('some value'); // not valid

Expected output:

jest.fn().mockResolvedValue('some value');

I will have a PR with a fix shortly.