UNPKG

intern

Version:

Intern. A next-generation code testing stack for JavaScript.

79 lines 3.54 kB
(function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports", "tslib", "./Reporter"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var Reporter_1 = tslib_1.__importStar(require("./Reporter")); var ConsoleReporter = (function (_super) { tslib_1.__extends(ConsoleReporter, _super); function ConsoleReporter(executor, options) { if (options === void 0) { options = {}; } var _this = _super.call(this, executor, options) || this; _this._hasGrouping = 'group' in _this.console && 'groupEnd' in _this.console; _this._testId = _this._hasGrouping ? 'name' : 'id'; return _this; } ConsoleReporter.prototype.error = function (error) { this.console.warn('FATAL ERROR'); this.console.error(this.formatError(error)); }; ConsoleReporter.prototype.suiteEnd = function (suite) { if (!this.console) { return; } if (suite.error) { this.console.warn('SUITE ERROR'); this.console.error(this.formatError(suite.error)); } else { var numTests = suite.numTests; var numFailedTests = suite.numFailedTests; var numSkippedTests = suite.numSkippedTests; var numNotRunTests = numTests - (suite.numPassedTests + numFailedTests + numSkippedTests); var message = numFailedTests + '/' + numTests + ' tests failed'; if (numSkippedTests + numNotRunTests > 0) { message += " (" + (numSkippedTests + numNotRunTests) + " not run)"; } this.console[numFailedTests ? 'warn' : 'info'](message); } this._hasGrouping && this.console.groupEnd(); }; ConsoleReporter.prototype.suiteStart = function (suite) { this._hasGrouping && suite.hasParent && this.console.group(suite.name); }; ConsoleReporter.prototype.testEnd = function (test) { if (test.error) { this.console.error("FAIL: " + test[this._testId] + " (" + test.timeElapsed + "ms)"); this.console.error(this.formatError(test.error)); } else if (test.skipped) { this.console.log("SKIP: " + test[this._testId] + " (" + test.skipped + ")"); } else { this.console.log("PASS: " + test[this._testId] + " (" + test.timeElapsed + "ms)"); } }; tslib_1.__decorate([ Reporter_1.eventHandler() ], ConsoleReporter.prototype, "error", null); tslib_1.__decorate([ Reporter_1.eventHandler() ], ConsoleReporter.prototype, "suiteEnd", null); tslib_1.__decorate([ Reporter_1.eventHandler() ], ConsoleReporter.prototype, "suiteStart", null); tslib_1.__decorate([ Reporter_1.eventHandler() ], ConsoleReporter.prototype, "testEnd", null); return ConsoleReporter; }(Reporter_1.default)); exports.default = ConsoleReporter; }); //# sourceMappingURL=Console.js.map