ts-jest: mocked() no longer seems to function correctly
I’m sort of surprised nobody else has encountered this, but I’m seeing it in two repos with quite different setups.
Issue
As of the latest Jest / ts-jest and @types/jest, any test runs throw errors for mock properties not existing on MockedFunction<>. For example:
error TS2339: Property 'mockRejectedValue' does not exist on type 'MockedFunction<RequestAPI<RequestPromise<any>, RequestPromiseOptions, RequiredUriUrl>>'.
29 requestMock.mockRejectedValue(new Error());
The setup itself is very very simple;
import { mocked } from 'ts-jest/utils';
jest.mock('request-promise-native');
import * as request from 'request-promise-native';
const requestMock = mocked(request);
afterEach(() => requestMock.mockRestore());
This looks like it might be similar to https://github.com/kulshekhar/ts-jest/issues/991
Expected behavior
mocked() works as in ts-jest 23.x
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 25
- Comments: 15 (3 by maintainers)
I’m in the process of merging 994 in. Unfortunately ts-jest is in a bit of a twilight zone right now, as none of the core maintainers have very much time to dedicate to it. We’re doing our best, but response times are probably going to be pretty slow until someone has more free time (or another contributor steps up to the plate)
Thanks for being polite about it.
Hey @GeeWee,
Any chance you or one of the other maintainers can review this? It’s been over a month, and your current release is broken / unusable.
If the library isn’t being maintained any more, that’s okay! Happy to fork, I don’t expect free work, but a quick yes / no would be wonderful.
Thanks
I’m using ts-jest 23.x. Downgrading @types/jest to 23.3.13 worked for me. Seems like the issue was in @types/jest 23.3.14.
@GeeWee Thanks for your help in merging this and thanks @kulshekhar for publishing!