doesErrorWithCallback(mockName, funcName, dataToReturn)

This is a variant of 'doesReturn'. It defines what to return from a mocked function during a failure scenario that expects results to be returned in a callback. There is absolutely no difference between 'doesErrorWithCallback' and 'doesReturnWithCallback'. It is instead up to user to define the response parameters in the dataToReturn array. In other words, if you want an error scenario, you just need to ensure the err object is defined in your dataToReturn array of parameters.

Maddox currently enforces a common paradigm for having the callback function be the last parameter. If you have a function that expects a callback, the callback must be the last parameter. Maddox will grab the callback from the last parameter and execute it with the provided 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 throw 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 passed into .
  • returns {Scenario}