k6-html-reporter
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -10,2 +10,3 @@ "use strict"; | ||
const ejs_1 = __importDefault(require("ejs")); | ||
const types_1 = require("./types"); | ||
function generate(options) { | ||
@@ -28,3 +29,3 @@ const resolvedInputPath = path_1.default.resolve(process.cwd(), options.jsonFile); | ||
const metricsData = content["metrics"]; | ||
const { checkMetric, countMetrics, timeMetrics, vusMetrics, allThresholds, metricThresholdsPassed, totalThresholdResult } = mapMetrics(metricsData); | ||
const { checkMetric, counterMetrics, trendMetrics, gaugeMetrics, rateMetrics, allThresholds, totalThresholdResult } = mapMetrics(metricsData); | ||
const checks = getChecks(checkRootGroupData).map((data) => { | ||
@@ -38,3 +39,3 @@ const splitedPath = data.path.split('::'); | ||
}); | ||
ejs_1.default.renderFile(templatePath, { checks, checkMetric, countMetrics, timeMetrics, vusMetrics, allThresholds, metricThresholdsPassed, totalThresholdResult, time }, {}, function (err, str) { | ||
ejs_1.default.renderFile(templatePath, { checks, rateMetrics, checkMetric, counterMetrics, trendMetrics, gaugeMetrics, allThresholds, totalThresholdResult, time }, {}, function (err, str) { | ||
if (err) { | ||
@@ -50,7 +51,7 @@ console.error(err); | ||
let checkMetric = {}; | ||
const countMetrics = []; | ||
const timeMetrics = []; | ||
const vusMetrics = []; | ||
const counterMetrics = []; | ||
const trendMetrics = []; | ||
const gaugeMetrics = []; | ||
const rateMetrics = []; | ||
const allThresholds = []; | ||
let metricThresholdsPassed = true; | ||
let totalThresholdResult = { | ||
@@ -62,77 +63,84 @@ passes: 0, | ||
Object.entries(data).forEach(([key, value]) => { | ||
const metric = { | ||
name: key, | ||
...value, | ||
thresholdFailed: undefined | ||
}; | ||
if (metric.type === 'counter') { | ||
if (value.thresholds) { | ||
const [passes, fails] = thresholdResult(value.thresholds); | ||
if (fails > 0) { | ||
totalThresholdResult.failedMetricsNum++; | ||
metricThresholdsPassed = false; | ||
} | ||
totalThresholdResult.passes += passes; | ||
totalThresholdResult.fails += fails; | ||
metric.thresholdFailed = fails > 0; | ||
allThresholds.push({ | ||
name: key, | ||
thresholds: value.thresholds | ||
}); | ||
if (value.type === types_1.MetricsType.COUNTER) { | ||
const { updatedThresholdResult, displayThreshold, metric } = handleMetricValues(key, value, totalThresholdResult); | ||
totalThresholdResult = { | ||
...totalThresholdResult, | ||
...updatedThresholdResult | ||
}; | ||
if (displayThreshold) { | ||
allThresholds.push(displayThreshold); | ||
} | ||
countMetrics.push(metric); | ||
counterMetrics.push(metric); | ||
} | ||
else if (metric.type === 'trend') { | ||
if (value.thresholds) { | ||
const [passes, fails] = thresholdResult(value.thresholds); | ||
if (fails > 0) { | ||
totalThresholdResult.failedMetricsNum++; | ||
metricThresholdsPassed = false; | ||
} | ||
totalThresholdResult.passes += passes; | ||
totalThresholdResult.fails += fails; | ||
metric.thresholdFailed = fails > 0; | ||
allThresholds.push({ | ||
name: key, | ||
thresholds: value.thresholds | ||
}); | ||
else if (value.type === types_1.MetricsType.TREND) { | ||
const { updatedThresholdResult, displayThreshold, metric } = handleMetricValues(key, value, totalThresholdResult); | ||
totalThresholdResult = { | ||
...totalThresholdResult, | ||
...updatedThresholdResult | ||
}; | ||
if (displayThreshold) { | ||
allThresholds.push(displayThreshold); | ||
} | ||
timeMetrics.push(metric); | ||
trendMetrics.push(metric); | ||
} | ||
else if (metric.name === 'checks') { | ||
if (value.thresholds) { | ||
const [passes, fails] = thresholdResult(value.thresholds); | ||
if (fails > 0) { | ||
totalThresholdResult.failedMetricsNum++; | ||
} | ||
totalThresholdResult.passes += passes; | ||
totalThresholdResult.fails += fails; | ||
metric.thresholdFailed = fails > 0; | ||
allThresholds.push({ | ||
name: key, | ||
thresholds: value.thresholds | ||
}); | ||
else if (key === 'checks') { | ||
const { updatedThresholdResult, displayThreshold, metric } = handleMetricValues(key, value, totalThresholdResult); | ||
totalThresholdResult = { | ||
...totalThresholdResult, | ||
...updatedThresholdResult | ||
}; | ||
if (displayThreshold) { | ||
allThresholds.push(displayThreshold); | ||
} | ||
checkMetric = metric; | ||
} | ||
else if (metric.type === 'gauge') { | ||
if (value.thresholds) { | ||
const [passes, fails] = thresholdResult(value.thresholds); | ||
if (fails > 0) { | ||
totalThresholdResult.failedMetricsNum++; | ||
metricThresholdsPassed = false; | ||
} | ||
totalThresholdResult.passes += passes; | ||
totalThresholdResult.fails += fails; | ||
metric.thresholdFailed = fails > 0; | ||
allThresholds.push({ | ||
name: key, | ||
thresholds: value.thresholds | ||
}); | ||
else if (value.type === types_1.MetricsType.GAUGE) { | ||
const { updatedThresholdResult, displayThreshold, metric } = handleMetricValues(key, value, totalThresholdResult); | ||
totalThresholdResult = { | ||
...totalThresholdResult, | ||
...updatedThresholdResult | ||
}; | ||
if (displayThreshold) { | ||
allThresholds.push(displayThreshold); | ||
} | ||
vusMetrics.push(metric); | ||
gaugeMetrics.push(metric); | ||
} | ||
else if (value.type === types_1.MetricsType.RATE && key !== 'checks') { | ||
const { updatedThresholdResult, displayThreshold, metric } = handleMetricValues(key, value, totalThresholdResult); | ||
totalThresholdResult = { | ||
...totalThresholdResult, | ||
...updatedThresholdResult | ||
}; | ||
if (displayThreshold) { | ||
allThresholds.push(displayThreshold); | ||
} | ||
rateMetrics.push(metric); | ||
} | ||
}); | ||
return { checkMetric, countMetrics, timeMetrics, vusMetrics, allThresholds, metricThresholdsPassed, totalThresholdResult }; | ||
return { checkMetric, counterMetrics, trendMetrics, gaugeMetrics, rateMetrics, allThresholds, totalThresholdResult }; | ||
} | ||
function handleMetricValues(key, value, currentTotalThresholdResult) { | ||
const metric = { | ||
name: key, | ||
...value, | ||
thresholdFailed: undefined | ||
}; | ||
const updatedThresholdResult = { ...currentTotalThresholdResult }; | ||
if (value.thresholds) { | ||
const [passes, fails] = thresholdResult(value.thresholds); | ||
if (fails > 0 && key !== 'checks') { | ||
updatedThresholdResult.failedMetricsNum++; | ||
} | ||
updatedThresholdResult.passes += passes; | ||
updatedThresholdResult.fails += fails; | ||
metric.thresholdFailed = fails > 0; | ||
return { | ||
displayThreshold: { | ||
name: key, | ||
thresholds: value.thresholds | ||
}, updatedThresholdResult, metric | ||
}; | ||
} | ||
return { updatedThresholdResult, metric }; | ||
} | ||
function thresholdResult(thresholds) { | ||
@@ -139,0 +147,0 @@ if (thresholds) { |
@@ -5,1 +5,12 @@ export declare type Options = { | ||
}; | ||
export declare enum MetricsType { | ||
GAUGE = "gauge", | ||
RATE = "rate", | ||
TREND = "trend", | ||
COUNTER = "counter" | ||
} | ||
export interface DisplayTotalThresholdResult { | ||
passes: number; | ||
fails: number; | ||
failedMetricsNum: number; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MetricsType = void 0; | ||
var MetricsType; | ||
(function (MetricsType) { | ||
MetricsType["GAUGE"] = "gauge"; | ||
MetricsType["RATE"] = "rate"; | ||
MetricsType["TREND"] = "trend"; | ||
MetricsType["COUNTER"] = "counter"; | ||
})(MetricsType = exports.MetricsType || (exports.MetricsType = {})); | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "k6-html-reporter", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A html reporter for k6", | ||
@@ -28,3 +28,6 @@ "main": "dist/index.js", | ||
"k6", | ||
"html" | ||
"html", | ||
"json to html", | ||
"k6 html reporter", | ||
"k6 summary report" | ||
], | ||
@@ -31,0 +34,0 @@ "author": "", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
29439
214
0