I've been trying to figure out how to implement the jest testing solution provided here (vanilla js) by the AWS team to work and so far I can't seem to make any headway. I get an error at .mockResolvedValue(expectedResult) as "Argument of type '{ isMock: boolean; }' is not assignable to parameter of type 'never'." However, I can't find a way to get around it. The function is cast above the describe block and follows the pattern shown at this StackOverflow post.
Any thoughts on what I'm doing wrong? I'm not super familiar with mocking like this so I could be missing something obvious. Also the pattern I have is pretty much the same as the code snippets AWS provides in the initial link.
transcribe client
import { TranscribeClient } from '@aws-sdk/client-transcribe';
const REGION = 'us-east-2';
// Create Transcribe service object.
export const transcribeClient = new TranscribeClient({ region: REGION });
transcribe test
import { createTranscribeJob } from './createJob';
import { transcribeClient } from '../../../../libs/transcribeClient';
jest.mock('../../../../libs/transcribeClient.ts');
const mockedTranscribeClient = transcribeClient as jest.Mocked<typeof transcribeClient>;
describe('@aws-sdk/client-transcribe mock', () => {
it('should successfully mock Transcribe client', async () => {
const expectedResult: { isMock: boolean } = { isMock: true };
mockedTranscribeClient.send.mockResolvedValue(expectedResult);
const response = await createTranscribeJob({
TranscriptionJobName: 'testName',
LanguageCode: 'en-US',
MediaFormat: 'mp4',
MediaUri: 'testUri',
});
expect(response.isMock).toEqual(true);
});
});