doesErrorWithPromise(mockName, funcName, dataToReturn)

This is a variant of 'doesReturn'. It defines what to return from a mocked function during a failure scenario that returns a promise. To force the error scenario, the mocked function will reject using the dataToReturn causing the first catch block to be invoked in your promise chain. Best practice dictates that you only throw Javascript Error objects. Therefore, you should be providing a Node Error object in the dataToReturn property.

  • mockName {String} - This is the key for the mock. It should match the key from 'mockThisFunction'.
  • funcName {String} - The name of the function to be mocked. Should match the name from 'mockThisFunction'.
  • dataToReturn {Error} - The Error object to be rejected.
  • returns {Scenario}