UNPKG

stryker-html-reporter

Version:

An html reporter for the JavaScript mutation testing framework Stryker

44 lines 2.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var typedHtml = require("typed-html"); var report_1 = require("stryker-api/report"); function mutantTable(mutants, sourceCode) { return typedHtml.createElement("table", { class: 'table table-sm table-hover mutant-table' }, typedHtml.createElement("thead", null, typedHtml.createElement("tr", null, typedHtml.createElement("th", null, "#"), typedHtml.createElement("th", null, "Mutator"), typedHtml.createElement("th", null, "State"), typedHtml.createElement("th", null, "Location"), typedHtml.createElement("th", null, "Original"), typedHtml.createElement("th", null, "Replacement"))), typedHtml.createElement("tbody", null, mutants.map(row(sourceCode)))); } exports.mutantTable = mutantTable; function row(sourceCode) { return function (numberedMutant) { var mutant = numberedMutant.mutant; return typedHtml.createElement("tr", null, typedHtml.createElement("th", null, numberedMutant.index), typedHtml.createElement("td", null, mutant.mutatorName), typedHtml.createElement("td", null, report_1.MutantStatus[numberedMutant.mutant.status]), typedHtml.createElement("td", null, mutant.location.start.line, ":", mutant.location.start.column), typedHtml.createElement("td", null, typedHtml.createElement("code", null, shorten(sourceCode.substring(mutant.range[0], mutant.range[1])))), typedHtml.createElement("td", null, typedHtml.createElement("code", null, shorten(mutant.replacement)))); }; } function shorten(input) { input = input.replace(/\w/g, ' ').trim(); if (input.length > 15) { return input.substr(0, 5) + "..." + input.substr(input.length - 5); } else { return input; } } //# sourceMappingURL=mutantTable.js.map