Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

128
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda