lundi 21 septembre 2020

Need help testing promise chains using jest

I have a function that looks like the following:

const func = () => 
  new Promise((resolve, reject) => 
    asyncFunc()
      .then(data => 
          axios.post('someAPI', {
          data 
        })  
      )
      .then(response => {
          asyncFunc1(response.data)
          resolve(response.data)
      })
      .catch(err => reject(err)
   );

I have read through the documentation of jest and mocking async functions, but it does not seem to cover the scope of this function. Can someone provide some insight into testing functions of this complexity?

Aucun commentaire:

Enregistrer un commentaire