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

607
Visualizações
Spyon method in jest - Cannot spyOn on a primitive value
const onSubmitClick = async () => {
var { isSuccess, result } = await callDispatch();
if (isSuccess) {
setValidStatus(true);
}
};

async function callDispatch() {
const result = call to server;
let isSuccess = result.success || (result.response && result.response.data.success);
return { isSuccess, result };
}

and in my test file

 import { EnterPin } from '../pages/enter-pin';
 jest.spyOn(EnterPin.prototype, 'callDispatch').mockImplementation(() =>{
  return 'true'
})
var button  = screen.getByRole('button');
fireEvent.click(button);

but i am getting Cannot spyOn on a primitive value; undefined given I tried below too but it didnot work

jest.spyOn(EnterPin.prototype, 'callDispatch').mockImplementation(() =>{
  return 'true'
})
var button  = screen.getByRole('button');
fireEvent.click(button);
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