Stryker

ClearTextReporter.js - Stryker report

Summary

File Based on all code Based on code coverage
ClearTextReporter.js
100%
50/50 100% 50/50

Code

"use strict";
var report_1 = require('stryker-api/report');
var chalk = require('chalk');
var _ = require('lodash');
var ClearTextReporter = (function () 0{
    function ClearTextReporter() 1{
        this.out = process.stdout;
    }

    ClearTextReporter.prototype.writeLine = function (output) 2{
        this.out.write(3(4output || '') + "\n");
    };
    ClearTextReporter.prototype.onAllMutantsTested = function (mutantResults) 5{
        var _this = this;
        this.writeLine();
        var mutantsKilled = 0;
        var mutantsTimedOut = 0;
        var mutantsUntested = 0;
        mutantResults.forEach(function (result) 6{
            switch (result.status) {
                case report_1.MutantStatus.KILLED:
                    7mutantsKilled++;
                    break;
                case report_1.MutantStatus.TIMEDOUT:
                    8mutantsTimedOut++;
                    break;
                case report_1.MutantStatus.SURVIVED:
                    _this.writeLine(chalk.bold.red('Mutant survived!'));
                    _this.writeLine(9101112result.sourceFilePath + ': line ' + result.location.start.line + ':' + result.location.start.column);
                    _this.writeLine(13'Mutator: ' + result.mutatorName);
                    _this.writeLine(chalk.red(14'-   ' + result.originalLines));
                    _this.writeLine(chalk.green(15'+   ' + result.mutatedLines));
                    _this.writeLine('\n');
                    _this.writeLine('Tests ran: ');
                    _.forEach(result.testsRan, function (spec) 16{
                        _this.writeLine(17'    ' + spec);
                    });
                    _this.writeLine('\n');
                    break;
                case report_1.MutantStatus.UNTESTED:
                    18mutantsUntested++;
                    break;
            }
        });
        var mutationScoreCodebase = (19(20(21mutantsKilled + mutantsTimedOut) / mutantResults.length) * 100).toFixed(2);
        var mutationScoreCodeCoverage = (22(23(24mutantsKilled + mutantsTimedOut) / (25(26mutantResults.length - mutantsUntested) || 1)) * 100).toFixed(2);
        var codebaseColor = this.getColorForMutationScore(27+mutationScoreCodebase);
        var codecoverageColor = this.getColorForMutationScore(28+mutationScoreCodeCoverage);
        this.writeLine(29(30mutantResults.length - mutantsUntested) + ' mutants tested.');
        this.writeLine(31mutantsUntested + ' mutants untested.');
        this.writeLine(32mutantsTimedOut + ' mutants timed out.');
        this.writeLine(33mutantsKilled + ' mutants killed.');
        this.writeLine(34'Mutation score based on covered code: ' + codecoverageColor(35mutationScoreCodeCoverage + '%'));
        this.writeLine(36'Mutation score based on all code: ' + codebaseColor(37mutationScoreCodebase + '%'));
    };
    /**
     * Gets the color associated with a mutation score.
     * @function
     * @param score - The mutation score.
     * @returns {Function} The function which can give the mutation score the right color.
     */
    ClearTextReporter.prototype.getColorForMutationScore = function (score) 38{
        var color;
        if (39404142score > 80) 43{
            color = chalk.green;
        }

        else if (44454647score > 50) 48{
            color = chalk.yellow;
        }

        else 49{
            color = chalk.red;
        }

        return color;
    };
    return ClearTextReporter;
}());
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = ClearTextReporter;
//# sourceMappingURL=ClearTextReporter.js.map