-
Notifications
You must be signed in to change notification settings - Fork 280
/
cli-reporter.js
57 lines (48 loc) · 1.94 KB
/
cli-reporter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Generated by CoffeeScript 1.6.3
var CliReporter, Reporter, logger,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
logger = require('./logger');
Reporter = require('./reporter');
CliReporter = (function(_super) {
__extends(CliReporter, _super);
function CliReporter(path) {
this.createReport = __bind(this.createReport, this);
this.addTest = __bind(this.addTest, this);
CliReporter.__super__.constructor.call(this);
this.type = "cli";
}
CliReporter.prototype.addTest = function(test, callback) {
CliReporter.__super__.addTest.call(this, test, function(error) {
if (error) {
return callback(error);
}
});
switch (test.status) {
case 'pass':
logger.pass(test.title);
break;
case 'fail':
logger.fail(test.title);
logger.fail(test.message);
logger.request("\n" + (JSON.stringify(test.request, null, 4)) + "\n");
logger.expected("\n" + (JSON.stringify(test.expected, null, 4)) + "\n");
logger.actual("\n" + (JSON.stringify(test.actual, null, 4)) + "\n\n");
}
return callback();
};
CliReporter.prototype.createReport = function(callback) {
CliReporter.__super__.createReport.call(this, function(error) {
if (error) {
return callback(error);
}
});
if (this.stats.tests > 0) {
logger.complete("" + this.stats.passes + " passing, " + this.stats.failures + " failing, " + (this.stats.tests - this.stats.failures - this.stats.passes) + " skipped");
}
return callback();
};
return CliReporter;
})(Reporter);
module.exports = CliReporter;