Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Unified stacktrace cleanup to happen in the reporter, removing an ext…

…ension of Jasmine
  • Loading branch information...
commit e85dfe36f06e190540287f6adc53e87ab9ff915b 1 parent 4dad5f7
@marcinbunsch marcinbunsch authored
View
12 lib/jessie/jasmine.js
@@ -42,18 +42,6 @@ jasmine.Spec.prototype.fail = function (e) {
expectationResult.pending = true
expectationResult.message = ['PENDING', e.message].join(': ')
}
- // Extract the stacktrace and remove the jasmine noise
- expectationResult.stacktrace = []
- if (e.stack) {
- var parts = e.stack.split(/\n\s+/)
- expectationResult.stacktrace.push(parts.shift())
- var regex = /(vendor|jessie)\/jasmine\.js:\d+:\d+\)*/
- for (var i = 0, len = parts.length; i < len; i++) {
- var line = parts[i]
- if (regex.test(line)) continue
- expectationResult.stacktrace.push(line)
- }
- }
this.results_.addResult(expectationResult);
};
View
66 lib/jessie/reporter.js
@@ -12,29 +12,29 @@ exports.reporter = function(format, callback) {
this.formatter = require('jessie/formatters/progress').formatter
}
var formatter = this.formatter
- this.formatter.reporter = this;
+ this.formatter.reporter = this;
}
// Wrapper around the formatter to log
-exports.reporter.prototype.log = function(suite) {
+exports.reporter.prototype.log = function(suite) {
if (this.formatter.log)
- this.formatter.log()
+ this.formatter.log()
}
// Wrapper around the formatter to render spec starting
-exports.reporter.prototype.reportSpecStarting = function(spec) {
+exports.reporter.prototype.reportSpecStarting = function(spec) {
if (this.formatter.specStart)
- this.formatter.specStart(spec)
+ this.formatter.specStart(spec)
if (this.formatter.reportSpecStarting)
this.formatter.reportSpecStarting(spec)
};
// Wrapper around the formatter to render suite starting
-exports.reporter.prototype.reportSuiteStarting = function(suite) {
+exports.reporter.prototype.reportSuiteStarting = function(suite) {
if (this.formatter.suiteStart)
- this.formatter.suiteStart(suite)
+ this.formatter.suiteStart(suite)
if (this.formatter.reportSuiteResults)
- this.formatter.reportSuiteResults(suite)
+ this.formatter.reportSuiteResults(suite)
};
// Wrapper around the formatter to render runner starting
@@ -43,7 +43,7 @@ exports.reporter.prototype.reportRunnerStarting = function(runner) {
if (this.formatter.start)
this.formatter.start()
if (this.formatter.reportRunnerStarting)
- this.formatter.reportRunnerStarting(runner)
+ this.formatter.reportRunnerStarting(runner)
}
// Wrapper around the formatter to render single spec results
@@ -61,26 +61,26 @@ exports.reporter.prototype.reportSpecResults = function(spec) {
this.formatter.spec(result, spec)
}
if (this.formatter.reportSpecResults)
- this.formatter.reportSpecResults(spec)
+ this.formatter.reportSpecResults(spec)
}
// Wrapper around the formatter to render suite results starting
exports.reporter.prototype.reportSuiteResults = function(suite) {
if (this.formatter.suite)
- this.formatter.suite({}, suite)
+ this.formatter.suite({}, suite)
if (this.formatter.reportSuiteResults)
- this.formatter.reportSuiteResults(suite)
+ this.formatter.reportSuiteResults(suite)
}
// Wrapper around the formatter to render run results
// Extracts useful info before passing it to the formatter
// Additionally, call the finish callback of present
exports.reporter.prototype.reportRunnerResults = function(runner) {
- var results = runner.results();
+ var results = runner.results();
var suites = runner.suites();
var result = {
failures: this.extractFailures(runner),
- pendings: this.extractPendings(runner)
+ pendings: this.extractPendings(runner)
}
result.total = 0
suites.forEach(function(suite) {
@@ -89,29 +89,29 @@ exports.reporter.prototype.reportRunnerResults = function(runner) {
result.duration = (Number(new Date) - this.start_time)
result.failed = result.failures.length
result.pending = result.pendings.length
-
+
if (this.formatter.finish)
- this.formatter.finish(result, runner);
+ this.formatter.finish(result, runner);
if (this.formatter.reportRunnerResults)
- this.formatter.reportRunnerResults(runner);
+ this.formatter.reportRunnerResults(runner);
var failed = result.failed > 0
- if (this.callback) this.callback(failed)
+ if (this.callback) this.callback(failed)
}
// Print an rspec-compatible summary of the run
exports.reporter.prototype.printSummary = function(result) {
- sys.puts('')
+ sys.puts('')
sys.puts('Completed in ' + (result.duration / 1000) + ' seconds')
if (result.failed > 0) {
- sys.print(ansi.red + result.total + " " + (result.total > 1 ? "examples" : "example") + ", " )
- sys.print(result.failed + " " + (result.failed > 1 ? "failures" : "failure") + "")
- if (result.pending > 0)
- sys.print(', ' + result.pending + " pending")
+ sys.print(ansi.red + result.total + " " + (result.total > 1 ? "examples" : "example") + ", " )
+ sys.print(result.failed + " " + (result.failed > 1 ? "failures" : "failure") + "")
+ if (result.pending > 0)
+ sys.print(', ' + result.pending + " pending")
sys.puts(ansi.none)
} else if (result.pending > 0) {
- sys.print(ansi.yellow + result.total + " " + (result.total > 1 ? "examples" : "example") + ", " )
- sys.puts(result.pending + " pending" + ansi.none)
+ sys.print(ansi.yellow + result.total + " " + (result.total > 1 ? "examples" : "example") + ", " )
+ sys.puts(result.pending + " pending" + ansi.none)
} else {
sys.puts(ansi.green + result.total + " " + (result.total > 1 ? "examples" : "example") + " " + ansi.none)
}
@@ -135,18 +135,19 @@ exports.reporter.prototype.collectFailedSpecItems = function(runner, filter) {
break
}
}
-
+
// If filter fails, return and continue with loop
if (!filter(found)) return
-
var stacktrace = found.stacktrace
if (!stacktrace) {
var stacktrace = []
try {
var parts = found.trace.stack.split(/\n\s+/)
- var regex = /(vendor\/jasmine\.js|jessie\/sugar\.js):\d+:\d+\)*/
+ var regex = /(vendor\/jasmine\.js|jessie\/sugar\.js|lib\/jessie\/jasmine\.js):\d+:\d+\)*/
+ var trace_verifier = /^at /
for (var i = 0, len = parts.length; i < len; i++) {
var line = parts[i]
+ if (!trace_verifier.test(line)) continue
if (regex.test(line)) continue
stacktrace.push(line.replace())
}
@@ -196,7 +197,7 @@ exports.reporter.prototype.extractPendings = function(runner) {
})
return pendings;
}
-// Extract the line of code
+// Extract the line of code
// Argument should be a string like this "file.js:1:1"
exports.reporter.prototype.extractFailureLine = function(line) {
try {
@@ -210,7 +211,7 @@ exports.reporter.prototype.extractFailureLine = function(line) {
var line = lines[parts[1]-1];
line = line.replace(/^\s+/, '').replace(/\s$/, '')
sys.puts(" " + ansi.red + '=> '+ line + ansi.none)
- }
+ }
} catch(e) {}
}
@@ -224,8 +225,7 @@ exports.reporter.prototype.printFailures = function(failures) {
sys.puts(' ' + (index + 1) + ') ' + failure.description )
sys.puts(" " + ansi.red + ' ' + failure.message + ansi.none)
var stacktrace = failure.stacktrace
- stacktrace.shift()
- if (stacktrace[0] && !failure.pending)
+ if (stacktrace[0] && !failure.pending)
reporter.extractFailureLine(stacktrace[0])
sys.print(ansi.grey)
stacktrace.forEach(function(line) {
@@ -246,7 +246,7 @@ exports.reporter.prototype.printPendings = function(failures) {
sys.puts(" " + ansi.yellow + ' ' + failure.message + ansi.none)
var stacktrace = failure.stacktrace
stacktrace.shift()
- if (stacktrace[0] && !failure.pending)
+ if (stacktrace[0] && !failure.pending)
reporter.extractFailureLine(stacktrace[0])
sys.print(ansi.grey)
stacktrace.forEach(function(line) {
View
2  spec/jessie/compatibility/JasmineCompatibilitySpec.js
@@ -1,7 +1,7 @@
describe('Jasmine Compabibility', function() {
it("should run this spec", function() {
-
+ expect(1).toEqual(1)
})
});
View
4 spec/jessie/jasmine_spec.js
@@ -1,9 +1,5 @@
describe('jessie.jasmine', function() {
- it('should extend jasmine.Spec.prototype.fail with stacktrace', function() {
- jasmine.Spec.prototype.fail.toString().should_match('expectationResult.stacktrace')
- })
-
it('should extend jasmine.PrettyPrinter.prototype.iterateObject with checking for should_ properties', function() {
jasmine.PrettyPrinter.prototype.iterateObject.toString().should_match('var should_regex')
})
Please sign in to comment.
Something went wrong with that request. Please try again.