Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
Jest + Typescript cannot mock AWS transcribe function

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);

  });
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!