Created
July 12, 2022 09:36
-
-
Save MarshalOfficial/2ed2d158f9cd15c6a8785466c0d05ecd to your computer and use it in GitHub Desktop.
k6 with html output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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