Filter Jasmine frames from stack traces

[Finishes #2644992]
This commit is contained in:
Steve Gravrock
2017-11-08 22:44:29 -08:00
parent 59ad217954
commit 5906a2c05c
8 changed files with 557 additions and 10 deletions

View File

@@ -100,5 +100,53 @@ getJasmineRequireObj().util = function(j$) {
return Object.prototype.hasOwnProperty.call(obj, key);
};
function anyMatch(pattern, lines) {
var i;
for (i = 0; i < lines.length; i++) {
if (lines[i].match(pattern)) {
return true;
}
}
return false;
}
function errorWithStack() {
// Don't throw and catch if we don't have to, because it makes it harder
// for users to debug their code with exception breakpoints.
var error = new Error();
if (error.stack) {
return error;
}
// But some browsers (e.g. Phantom) only provide a stack trace if we throw.
try {
throw new Error();
} catch (e) {
return e;
}
}
function callerFile() {
var trace = new j$.StackTrace(errorWithStack().stack);
return trace.frames[2].file;
}
util.jasmineFile = (function() {
var result;
return function() {
var trace;
if (!result) {
result = callerFile();
}
return result;
};
}());
return util;
};