UNPKG

3.54 kBJavaScriptView Raw
1(function (factory) {
2 if (typeof module === "object" && typeof module.exports === "object") {
3 var v = factory(require, exports);
4 if (v !== undefined) module.exports = v;
5 }
6 else if (typeof define === "function" && define.amd) {
7 define(["require", "exports", "tslib", "./Reporter"], factory);
8 }
9})(function (require, exports) {
10 "use strict";
11 Object.defineProperty(exports, "__esModule", { value: true });
12 var tslib_1 = require("tslib");
13 var Reporter_1 = tslib_1.__importStar(require("./Reporter"));
14 var ConsoleReporter = (function (_super) {
15 tslib_1.__extends(ConsoleReporter, _super);
16 function ConsoleReporter(executor, options) {
17 if (options === void 0) { options = {}; }
18 var _this = _super.call(this, executor, options) || this;
19 _this._hasGrouping = 'group' in _this.console && 'groupEnd' in _this.console;
20 _this._testId = _this._hasGrouping ? 'name' : 'id';
21 return _this;
22 }
23 ConsoleReporter.prototype.error = function (error) {
24 this.console.warn('FATAL ERROR');
25 this.console.error(this.formatError(error));
26 };
27 ConsoleReporter.prototype.suiteEnd = function (suite) {
28 if (!this.console) {
29 return;
30 }
31 if (suite.error) {
32 this.console.warn('SUITE ERROR');
33 this.console.error(this.formatError(suite.error));
34 }
35 else {
36 var numTests = suite.numTests;
37 var numFailedTests = suite.numFailedTests;
38 var numSkippedTests = suite.numSkippedTests;
39 var numNotRunTests = numTests - (suite.numPassedTests + numFailedTests + numSkippedTests);
40 var message = numFailedTests + '/' + numTests + ' tests failed';
41 if (numSkippedTests + numNotRunTests > 0) {
42 message += " (" + (numSkippedTests + numNotRunTests) + " not run)";
43 }
44 this.console[numFailedTests ? 'warn' : 'info'](message);
45 }
46 this._hasGrouping && this.console.groupEnd();
47 };
48 ConsoleReporter.prototype.suiteStart = function (suite) {
49 this._hasGrouping && suite.hasParent && this.console.group(suite.name);
50 };
51 ConsoleReporter.prototype.testEnd = function (test) {
52 if (test.error) {
53 this.console.error("FAIL: " + test[this._testId] + " (" + test.timeElapsed + "ms)");
54 this.console.error(this.formatError(test.error));
55 }
56 else if (test.skipped) {
57 this.console.log("SKIP: " + test[this._testId] + " (" + test.skipped + ")");
58 }
59 else {
60 this.console.log("PASS: " + test[this._testId] + " (" + test.timeElapsed + "ms)");
61 }
62 };
63 tslib_1.__decorate([
64 Reporter_1.eventHandler()
65 ], ConsoleReporter.prototype, "error", null);
66 tslib_1.__decorate([
67 Reporter_1.eventHandler()
68 ], ConsoleReporter.prototype, "suiteEnd", null);
69 tslib_1.__decorate([
70 Reporter_1.eventHandler()
71 ], ConsoleReporter.prototype, "suiteStart", null);
72 tslib_1.__decorate([
73 Reporter_1.eventHandler()
74 ], ConsoleReporter.prototype, "testEnd", null);
75 return ConsoleReporter;
76 }(Reporter_1.default));
77 exports.default = ConsoleReporter;
78});
79//# sourceMappingURL=Console.js.map
\No newline at end of file