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

183
Visualizações
node Jest FT async service calls failing when returning promise

I'm seeing an issue where in my code I have an async functional test which calls our api at a certain route which is just an async call that works fine

  const response = await callOurApp(
        req,
        stuff
      );

but then later down in the FT I am calling another endpoint from another service like so but this fails with TypeError: Cannot read property 'then' of undefined

const newQuery = await getNewStuff(req);

does it have to do with the way the promise is handled in the function since this function is also calling another service? or is there something I need to do in Jest to allow this behavior in my FT?

here is the function below.... this function is calling the request method for another service which we make an instance of when we are running our api

export async function getNewStuff(req) {
  const payload = {
    method: 'GET',
    path: '/path/to/the/resource',
    headers: {'stuff'},
  };
  req.log('debug', 'GET_PAYMENT_TOKEN_REQ_PAYLOAD', {
    result: JSON.stringify(payload),
  });
  return theService.request(req, payload).then(result => {
    return result;
  });
}
about 4 years ago · Santiago Trujillo
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