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 }; }y en mi archivo de prueba
import { EnterPin } from '../pages/enter-pin'; jest.spyOn(EnterPin.prototype, 'callDispatch').mockImplementation(() =>{ return 'true' }) var button = screen.getByRole('button'); fireEvent.click(button);pero obtengo No se puede espiar en un valor primitivo; indefinido dado que probé a continuación también pero no funcionó
jest.spyOn(EnterPin.prototype, 'callDispatch').mockImplementation(() =>{ return 'true' }) var button = screen.getByRole('button'); fireEvent.click(button);