You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use ts-jest to mock one of my dependencies. This dependency (auth0.ManageClient) has multiple definitions for a same method and overrides it based on the params you pass it:
When trying to mock the getRoles method, I get the following message: Argument of type X is not assignable to parameter of type 'never'.
I think this is because ts-jest is expecting me to override the getRoles(cb: (err: Error, roles: Role[]) => void): void; which is not what I am trying to do. I want to mock its result with .mockResolvedValue.
To Reproduce
import { ManagementClient } from 'auth0';
import { MockedObjectDeep } from 'ts-jest/dist/utils/testing';
import { mocked } from 'ts-jest/utils';
jest.mock('auth0');
describe('UsersService', () => {
let manageClient: MockedObjectDeep<ManagementClient>;
beforeEach(() => {
jest.clearAllMocks();
manageClient = mocked(
new ManagementClient({
domain: 'DOMAIN',
clientId: 'CLIENT_ID',
clientSecret: 'CLIENT_SECRET',
}),
true
);
});
describe('updateUserRoles', () => {
beforeEach(() => {
manageClient.getRoles.mockResolvedValue([]); // error will show here
});
it('should test something', async () => {
// ...
});
});
});
Expected behavior
Typings should support method overriding.
The text was updated successfully, but these errors were encountered:
The same problem is occuring when using @aws-sdk modules:
import{Readable}from'stream'import{mocked}from'ts-jest/utils'import{S3}from'@aws-sdk/client-s3'jest.mock('@aws-sdk/client-s3')constS3Mock=mocked(S3,true)test('get-object',asyncfunction(){constdata=Readable.from('data')// TS2322: Type 'Readable' is not assignable to type 'never'.S3Mock.prototype.getObject.mockResolvedValue({Body: data})})
🐛 Bug Report
I am trying to use
ts-jest
to mock one of my dependencies. This dependency (auth0.ManageClient
) has multiple definitions for a same method and overrides it based on the params you pass it:When trying to mock the
getRoles
method, I get the following message:Argument of type X is not assignable to parameter of type 'never'
.I think this is because
ts-jest
is expecting me to override thegetRoles(cb: (err: Error, roles: Role[]) => void): void;
which is not what I am trying to do. I want to mock its result with.mockResolvedValue
.To Reproduce
Expected behavior
Typings should support method overriding.
The text was updated successfully, but these errors were encountered: