Skip to content

Commit

Permalink
Merge pull request benc-uk#16 from benc-uk/vnext
Browse files Browse the repository at this point in the history
Adds request failure count
  • Loading branch information
benc-uk authored Mar 16, 2021
2 parents a522a26 + 2f23160 commit ab6fea5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/bundle.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/html-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ejs from "../node_modules/ejs/ejs.min.js"
import template from "./template.ejs"

const version = "2.1.1"
const version = "2.2.0"

//
// Main function should be imported and wrapped with the function handleSummary
Expand All @@ -29,8 +29,8 @@ export function htmlReport(data, opts = {}) {
if (data.metrics[metricName].thresholds) {
thresholdCount++
let thresholds = data.metrics[metricName].thresholds
for (let t in thresholds) {
if (!thresholds[t].ok) {
for (let thresName in thresholds) {
if (!thresholds[thresName].ok) {
thresholdFailures++
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/template.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
left: 50%;
transform: translate(-50%, -50%);
color: #0000002d;
font-size: 9vw;
font-size: 8vw;
z-index: 1;
}
.metricbox {
Expand All @@ -144,9 +144,14 @@
<div class="row">
<div class="box">
<i class="fas fa-globe icon"></i>
<h4>Requests</h4>
<h4>Total Requests</h4>
<% if(data.metrics.http_reqs) { %><div class="bignum"><%= data.metrics.http_reqs.values.count %></div><% } %>
</div>
<div class="box <% if(data.metrics.http_req_failed && data.metrics.http_req_failed.values.passes > 0) { %> failed <% } %>">
<i class="far fa-times-circle icon"></i>
<h4>Failed Requests</h4>
<% if(data.metrics.http_req_failed) { %><div class="bignum"><%= data.metrics.http_req_failed.values.passes %></div><% } %>
</div>
<div class="box <% if(thresholdFailures > 0) { %> failed <% } %>">
<i class="fas fa-chart-bar icon"></i>
<h4>Breached Thresholds</h4>
Expand Down
6 changes: 3 additions & 3 deletions tests/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const SLEEP = __ENV.SLEEP || 1;

export function handleSummary(data) {
return {
"example.html": htmlReport(data),
"example1.html": htmlReport(data),
stdout: textSummary(data, { indent: " ", enableColors: true }),
};
}
Expand All @@ -34,9 +34,9 @@ export let options = {
},
};

// Totally generic HTTP check
export default function () {
let res = http.get(TARGET_URL);
let url = Math.random() > 0.5 ? TARGET_URL : TARGET_URL + "/gibberish";
let res = http.get(url);

check(res, {
"Status is ok": (r) => r.status === 200,
Expand Down

0 comments on commit ab6fea5

Please sign in to comment.