Jest mock the same function twice with different arguments

后端 未结 2 1619
不思量自难忘°
不思量自难忘° 2021-01-17 07:59

I\'m new to JEST and I\'m currently testing a Javascript component that makes an API call in its onComponentDidMount. Depending on the return data of the ajax call (api call

2条回答
  •  天命终不由人
    2021-01-17 08:47

    Please check the Jest docs on this. You can return different values when mocking a function and once return a value you wish and then later a different value.

提交回复
热议问题