Testing a CallBack function in a function which get triggered forButton Onclick using jest

I have a React child component which has button

export function Banner({argumentSetter}){
function handleOnClick(){
  <Button onClick={handleOnClick}>
    <Icon name="delete" type="filled">

And I have my argumentSetter in my parent component defined as following,

const [argument,setArgument] = useState<Argument>(argument.EDIT);
argumentSetter = useCallBack((val)=>{

    <Banner argumentSetter={argumentSetter}/>

How to get 100% test coverage using jest.

Source: React – Stack Overflow

November 22, 2021
Category : News
Tags: jestjs | mocking | reactjs | spy

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.