stryker-html-reporter
Version:
An html reporter for the JavaScript mutation testing framework Stryker
87 lines • 5.22 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var path = require("path");
var typedHtml = require("typed-html");
var UrlHelper_1 = require("./UrlHelper");
function resultTable(model, title, thresholds) {
return typedHtml.createElement("table", { class: 'table table-sm table-hover table-bordered table-no-top' },
head,
tbody(model, title, thresholds));
}
exports.resultTable = resultTable;
var head = typedHtml.createElement("thead", null,
typedHtml.createElement("tr", null,
typedHtml.createElement("th", { style: 'width: 20%' },
typedHtml.createElement("div", null,
typedHtml.createElement("span", null, "File / Directory"))),
typedHtml.createElement("th", { colspan: '2' },
typedHtml.createElement("div", null,
typedHtml.createElement("span", null, "Mutation score"))),
typedHtml.createElement("th", { class: 'rotate text-center', style: 'width: 50px' },
typedHtml.createElement("div", null,
typedHtml.createElement("span", null, "# Killed"))),
typedHtml.createElement("th", { class: 'rotate text-center', style: 'width: 50px' },
typedHtml.createElement("div", null,
typedHtml.createElement("span", null, "# Survived"))),
typedHtml.createElement("th", { class: 'rotate text-center', style: 'width: 50px' },
typedHtml.createElement("div", null,
typedHtml.createElement("span", null, "# Timeout"))),
typedHtml.createElement("th", { class: 'rotate text-center', style: 'width: 50px' },
typedHtml.createElement("div", null,
typedHtml.createElement("span", null, "# No coverage"))),
typedHtml.createElement("th", { class: 'rotate text-center', style: 'width: 50px' },
typedHtml.createElement("div", null,
typedHtml.createElement("span", null, "# Runtime errors"))),
typedHtml.createElement("th", { class: 'rotate text-center', style: 'width: 50px' },
typedHtml.createElement("div", null,
typedHtml.createElement("span", null, "# Transpile errors"))),
typedHtml.createElement("th", { class: 'rotate rotate-width-70 text-center', style: 'width: 70px' },
typedHtml.createElement("div", null,
typedHtml.createElement("span", null, "Total detected"))),
typedHtml.createElement("th", { class: 'rotate rotate-width-70 text-center', style: 'width: 70px' },
typedHtml.createElement("div", null,
typedHtml.createElement("span", null, "Total undetected"))),
typedHtml.createElement("th", { class: 'rotate rotate-width-70 text-center', style: 'width: 70px' },
typedHtml.createElement("div", null,
typedHtml.createElement("span", null, "Total mutants")))));
function tbody(model, title, thresholds) {
return typedHtml.createElement("tbody", null,
row(model, title, thresholds),
model.childResults.map(function (childResult) { return childRow(childResult, thresholds); }));
}
function childRow(model, thresholds) {
return row(model, " " + typedHtml.createElement("a", { href: UrlHelper_1.default.relativeUrl(model) }, model.name + (model.representsFile ? '' : path.sep)), thresholds);
}
function row(model, title, thresholds) {
var mutationScoreRounded = model.mutationScore.toFixed(2);
var coloringClass = getColoringClass(model.mutationScore, thresholds);
return typedHtml.createElement("tr", null,
typedHtml.createElement("td", null, title),
typedHtml.createElement("td", null,
typedHtml.createElement("div", { class: 'progress' },
typedHtml.createElement("div", { class: 'progress-bar bg-' + coloringClass, role: 'progressbar', "aria-valuenow": mutationScoreRounded, "aria-valuemin": '0', "aria-valuemax": '100', style: "width: " + mutationScoreRounded + "%;" },
mutationScoreRounded,
"%"))),
typedHtml.createElement("th", { class: 'text-center text-' + coloringClass, style: 'width: 10%' }, mutationScoreRounded),
typedHtml.createElement("td", { class: 'text-center' }, model.killed),
typedHtml.createElement("td", { class: 'text-center' }, model.survived),
typedHtml.createElement("td", { class: 'text-center' }, model.timedOut),
typedHtml.createElement("td", { class: 'text-center' }, model.noCoverage),
typedHtml.createElement("td", { class: 'text-center' }, model.runtimeErrors),
typedHtml.createElement("td", { class: 'text-center' }, model.transpileErrors),
typedHtml.createElement("th", { class: 'text-center' }, model.totalDetected),
typedHtml.createElement("th", { class: 'text-center' }, model.totalUndetected),
typedHtml.createElement("th", { class: 'text-center' }, model.totalMutants));
}
function getColoringClass(score, thresholds) {
if (score < thresholds.low) {
return 'danger';
}
else if (score < thresholds.high) {
return 'warning';
}
else {
return 'success';
}
}
//# sourceMappingURL=resultTable.js.map