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);
Via Active questions tagged javascript - Stack Overflow https://ift.tt/9fnX31D
Comments
Post a Comment