Skip to content

Instantly share code, notes, and snippets.

@MarshalOfficial
Created July 12, 2022 09:36
Show Gist options
  • Select an option

  • Save MarshalOfficial/2ed2d158f9cd15c6a8785466c0d05ecd to your computer and use it in GitHub Desktop.

Select an option

Save MarshalOfficial/2ed2d158f9cd15c6a8785466c0d05ecd to your computer and use it in GitHub Desktop.
k6 with html output
import http from 'k6/http';
import {
check
} from 'k6';
import { htmlReport } from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js";
export default function () {
try {
let str = 'https://google.com'
const requestHeaders = {
Authorization: 'Bearer jwt token'
};
let res = http.get(str, { headers: requestHeaders });
const result = check(res, {
'status was 200': (r) => r.status == 200
});
if (!result) {
console.log(JSON.stringify(res));
process.exit();
}
} catch (err) {
console.log(err);
}
}
export function handleSummary(data) {
return {
"summary.html": htmlReport(data),
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment