Sanjo/meteor-jasmine — pull request #31 by tomitrescak (2014-09-30 23:51:15+00:00)
Title: Improved stack trace parsing

Sanjo, here is the improved stack trace parsing. I'm not sure why GitHub is showing so many changes since most of them you have already integrated into master branch and I can see them. Basically the only thing that is new is this part in JasmineTestFramework.

```javascript
getJasmineConsoleReporter = function(searchString, showMessage) {
// override original behavior to cut stack trace (dirty, in order not to modify the console)
var consoleReporter = new jasmine.ConsoleReporter({
print: util.print,
showColors: true,
timer: new jasmine.Timer()
});
consoleReporter.id = id++;

var originalReport = consoleReporter.specDone;
var that = this;
consoleReporter.specDone = function(result) {
var indent = function(str) {
if (str[0] != " ") str = " " + str;
return str.replace(" ", " ");
}

if (result.status == "failed" && result.failedExpectations.length > 0) {
// simplify stack trace
for (var i = 0; i < result.failedExpectations.length; i++) {
var failedExpectation = result.failedExpectations[i];

if (failedExpectation.stack) {
var newStack = "",
reg = new RegExp(".*" + searchString + ".*");

failedExpectation.stack.split("\n").every(function(elem) {
// when we find the stack trace part with the search string we can finish
if (elem.match(reg)) {
newStack += elem + "\n";
return false;
}
// we add all non-jasmine framework element lines containing stack information
if (!elem.match(/sanjo[:_]jasmine/) && elem.match(/^ *at/)) {
newStack += elem + "\n";
}
return true;
});

// rebuild the stack
failedExpectation.stack = "Error: " +
failedExpectation.message + "\n" +
newStack;

} else {
// in case there is no stack we only show the message
failedExpectation.stack = "Error: " + failedExpectation.message + "\n No stack trace available.";
}
}
}
originalReport(result);
}

return consoleReporter;
}
}
```