@hirez_io/auto-spies-core
Version:
Create automatic spies from classes in tests, also for promises and observables, used as a common code for jasmine-auto-spies and jest-auto-spies
20 lines • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.errorHandler = void 0;
var javascript_stringify_1 = require("javascript-stringify");
exports.errorHandler = {
throwArgumentsError: function (actualArgs, functionName) {
var errorMessage = "\n The function '".concat(functionName, "' was configured with\n 'mustBeCalledWith' and expects to be called with specific arguments.\n -\n ");
if (!actualArgs || actualArgs.length === 0) {
errorMessage += "\n But the function was called without any arguments\n ";
}
else {
var formattedArgs = (0, javascript_stringify_1.stringify)(actualArgs);
/* istanbul ignore next */
formattedArgs = formattedArgs === null || formattedArgs === void 0 ? void 0 : formattedArgs.substring(1, formattedArgs.length - 1);
errorMessage += "\n But the actual arguments were: ".concat(formattedArgs, "\n ");
}
throw new Error(errorMessage);
},
};
//# sourceMappingURL=error-handler.js.map