Files
edx-platform/common/static/common/js/jasmine_stack_trace.js
2016-08-08 15:59:18 -04:00

29 lines
1.0 KiB
JavaScript

/* This file overrides ExceptionFormatter of jasmine before it's initialization in karma-jasmine's
boot.js. It's important because ExceptionFormatter returns a constructor function. Once the method has been
initialized we can't override the ExceptionFormatter as Jasmine then uses the stored reference to the function */
(function() {
/* globals jasmineRequire */
'use strict';
var OldExceptionFormatter = jasmineRequire.ExceptionFormatter(),
oldExceptionFormatter = new OldExceptionFormatter(),
MAX_STACK_TRACE_LINES = 10;
jasmineRequire.ExceptionFormatter = function() {
function ExceptionFormatter() {
this.message = oldExceptionFormatter.message;
this.stack = function(error) {
var errorMsg = null;
if (error) {
errorMsg = error.stack.split('\n').slice(0, MAX_STACK_TRACE_LINES).join('\n');
}
return errorMsg;
};
}
return ExceptionFormatter;
};
}());