var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
(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", "./Reporter"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var Reporter_1 = require("./Reporter");
    /**
     * The console reporter outputs to the browser console.
     */
    var ConsoleReporter = (function (_super) {
        __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) {
            // IE<10 does not provide a global console object when Developer Tools is turned off
            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 message = numFailedTests + '/' + numTests + ' tests failed';
                if (numSkippedTests > 0) {
                    message += ' (' + numSkippedTests + ' skipped)';
                }
                this.console[numFailedTests ? 'warn' : 'info'](message);
            }
            this._hasGrouping && this.console.groupEnd();
        };
        ConsoleReporter.prototype.suiteStart = function (suite) {
            // only start group for non-root 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)");
            }
        };
        __decorate([
            Reporter_1.eventHandler()
        ], ConsoleReporter.prototype, "error", null);
        __decorate([
            Reporter_1.eventHandler()
        ], ConsoleReporter.prototype, "suiteEnd", null);
        __decorate([
            Reporter_1.eventHandler()
        ], ConsoleReporter.prototype, "suiteStart", null);
        __decorate([
            Reporter_1.eventHandler()
        ], ConsoleReporter.prototype, "testEnd", null);
        return ConsoleReporter;
    }(Reporter_1.default));
    exports.default = ConsoleReporter;
});
//# sourceMappingURL=Console.js.map