Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fziviello/k6-report-html
Create Report html for k6
https://github.com/fziviello/k6-report-html
k6 k6-extension
Last synced: 11 days ago
JSON representation
Create Report html for k6
- Host: GitHub
- URL: https://github.com/fziviello/k6-report-html
- Owner: fziviello
- License: mit
- Created: 2022-11-15T08:55:53.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-18T21:43:30.000Z (about 2 years ago)
- Last Synced: 2024-11-06T10:27:06.170Z (2 months ago)
- Topics: k6, k6-extension
- Language: EJS
- Homepage: https://www.linkedin.com/in/programmatore/
- Size: 655 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# K6 Report HTML
[![CI Checks & Build](https://github.com/fziviello/k6-report-html/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/fziviello/k6-report-html/actions/workflows/ci.yaml)
### Description
The report will show all request groups, checks, HTTP metrics and other statistics
Any HTTP metrics which have failed thresholds will be highlighted in red. Any group checks with more than 0 failures will also be shown in red.
# Locally Usage
This extension to K6 is intended to be used by adding into your K6 test code (JavaScript) and utilizes the _handleSummary_ callback hook, added to K6 last version.
When your test completes a HTML file will be written to the filesystem, containing a formatted and easy to consume version of the test summary dataTo use, add this module to your test code.
Import the `reportHTML` function from the bundled module hosted remotely on GitHub
```js
import { reportHTML } from "https://raw.githubusercontent.com/fziviello/k6-report-html/main/dist/reportHtml.min.js";
```Then outside the test's default function, wrap it with the `handleSummary(data)` function which [K6 calls at the end of any test](https://github.com/loadimpact/k6/pull/1768), as follows:
```js
export function handleSummary(data) {
return {
"report.html": reportHTML(data),
};
}
```The key used in the returned object is the filename that will be written to, and can be any valid filename or path
The **reportHTML** function takes a map as a second parameter, you can use the title key to customize the title of the report
```ts
reportHTML(data,{title:"Custom Title"}),
```## Merged outputs
If you want more control over the output produced or to output the summary into multiple places (including stdout), just combine the result of reportHTML with other summary generators, as follows:
```js
// This will export to HTML as filename "result.html" AND also stdout using the text summary
import { reportHTML } from "https://raw.githubusercontent.com/fziviello/k6-report-html/main/dist/reportHtml.min.js";
import { textSummary } from "https://jslib.k6.io/k6-summary/0.0.1/index.js";export function handleSummary(data) {
return {
"report.html": reportHTML(data),
stdout: textSummary(data, { indent: " ", enableColors: true }),
};
}
```
# Screenshots![main report screenshot](https://github.com/fziviello/k6-report-html/blob/main/screenshots/screen1.png)
![another report screenshot](https://github.com/fziviello/k6-report-html/blob/main/screenshots/screen2.png)
![another report screenshot](https://github.com/fziviello/k6-report-html/blob/main/screenshots/screen3.png)