k6-modern-reporter 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +2 -0
- package/LICENSE +21 -0
- package/README.md +182 -0
- package/assets/checks.jpeg +0 -0
- package/assets/metrics.jpeg +0 -0
- package/assets/overview.jpeg +0 -0
- package/assets/thresholds.jpeg +0 -0
- package/k6-modern-reporter.js +1291 -0
- package/package.json +28 -0
- package/reports/test-reporter-2026-01-31T16-39-41.613Z.html +847 -0
- package/test-reporter.ts +59 -0
package/.gitattributes
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Samin Azhan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# k6-modern-reporter
|
|
2
|
+
|
|
3
|
+
A modern, beautiful HTML report generator for k6 performance tests with an interactive UI, responsive design, and comprehensive metrics visualization.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
✨ **Modern UI Design**
|
|
8
|
+
|
|
9
|
+
- Gradient backgrounds and smooth animations
|
|
10
|
+
- Responsive layout that works on all devices
|
|
11
|
+
- Interactive tabbed interface
|
|
12
|
+
- Professional color scheme with intuitive visual indicators
|
|
13
|
+
|
|
14
|
+
📊 **Comprehensive Metrics**
|
|
15
|
+
|
|
16
|
+
- Performance overview with key statistics
|
|
17
|
+
- Detailed HTTP request metrics (duration, waiting, connecting, TLS, etc.)
|
|
18
|
+
- Data transfer statistics (sent/received)
|
|
19
|
+
- Request success/failure rates
|
|
20
|
+
- P90, P95, and percentile breakdowns
|
|
21
|
+
|
|
22
|
+
✅ **Test Validation**
|
|
23
|
+
|
|
24
|
+
- Visual check results with pass/fail counts
|
|
25
|
+
- Threshold status and validation results
|
|
26
|
+
- Overall test status indicator
|
|
27
|
+
- Detailed error tracking
|
|
28
|
+
|
|
29
|
+
🎯 **Customizable Reports**
|
|
30
|
+
|
|
31
|
+
- Custom titles and subtitles
|
|
32
|
+
- HTTP method display
|
|
33
|
+
- Additional test information sections
|
|
34
|
+
- Debug mode for troubleshooting
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
1. Run `npm i k6-modern-reporter` into your k6 project
|
|
39
|
+
2. Import `htmlReport` in your script:
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import { htmlReport } from 'k6-modern-reporter';
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage
|
|
46
|
+
|
|
47
|
+
### Basic Setup
|
|
48
|
+
|
|
49
|
+
Example of a k6 test script:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import http from 'k6/http';
|
|
53
|
+
import { check } from 'k6';
|
|
54
|
+
import { htmlReport } from 'k6-modern-reporter';
|
|
55
|
+
|
|
56
|
+
export const options = {
|
|
57
|
+
scenarios: {
|
|
58
|
+
shared_iteration: {
|
|
59
|
+
executor: 'shared-iterations',
|
|
60
|
+
vus: 50,
|
|
61
|
+
iterations: 100,
|
|
62
|
+
maxDuration: '60s',
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
thresholds: {
|
|
66
|
+
'http_req_failed': ['rate==0.00'],
|
|
67
|
+
'http_req_duration': ['p(95)<1000'],
|
|
68
|
+
'checks': ['rate==1.00'],
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default function () {
|
|
73
|
+
const response = http.get("https://httpbin.org/get");
|
|
74
|
+
|
|
75
|
+
check(response, {
|
|
76
|
+
'Response status 200': (r) => r.status === 200,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Generate the HTML report
|
|
81
|
+
export function handleSummary(data) {
|
|
82
|
+
const reportFileName = `./test-report-${new Date().toJSON().split(':').join('-')}.html`;
|
|
83
|
+
return {
|
|
84
|
+
[reportFileName]: htmlReport(data)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Report Layout
|
|
90
|
+
|
|
91
|
+
The generated HTML report includes the following sections, accessible via interactive tabs:
|
|
92
|
+
|
|
93
|
+
### 📈 Overview Tab (Default)
|
|
94
|
+
|
|
95
|
+

|
|
96
|
+
|
|
97
|
+
#### Performance Overview
|
|
98
|
+
|
|
99
|
+
- Total Requests counter
|
|
100
|
+
- Success Rate percentage
|
|
101
|
+
- Failed Requests count
|
|
102
|
+
- Overall Test Status (PASS/FAIL indicator)
|
|
103
|
+
|
|
104
|
+
#### Data Transfer
|
|
105
|
+
|
|
106
|
+
- Bytes received across all requests
|
|
107
|
+
- Bytes sent across all requests
|
|
108
|
+
- Avg request size
|
|
109
|
+
- Total data transferred
|
|
110
|
+
|
|
111
|
+
### 📊 Metrics Tab
|
|
112
|
+
|
|
113
|
+

|
|
114
|
+
|
|
115
|
+
Detailed HTTP request metrics table showing:
|
|
116
|
+
|
|
117
|
+
- **http_req_duration**: Total request time (Avg, Min, Median, Max, P90, P95)
|
|
118
|
+
- **http_req_waiting**: Server processing time
|
|
119
|
+
- **http_req_connecting**: TCP connection establishment time
|
|
120
|
+
- **http_req_tls_handshaking**: TLS/SSL handshake time
|
|
121
|
+
- **http_req_receiving**: Response download time
|
|
122
|
+
- **http_req_sending**: Request upload time
|
|
123
|
+
|
|
124
|
+
Color-coded values:
|
|
125
|
+
|
|
126
|
+
- 🟢 **Green**: Good performance metrics
|
|
127
|
+
- 🔴 **Red**: Poor performance metrics
|
|
128
|
+
|
|
129
|
+
### ✅ Checks Tab
|
|
130
|
+
|
|
131
|
+

|
|
132
|
+
|
|
133
|
+
Displays all test checks organized by groups with:
|
|
134
|
+
|
|
135
|
+
- Check name and description
|
|
136
|
+
- Pass count (green badge)
|
|
137
|
+
- Fail count (red badge)
|
|
138
|
+
- Pass/Fail rate percentage
|
|
139
|
+
|
|
140
|
+
### 🎯 Thresholds Tab
|
|
141
|
+
|
|
142
|
+

|
|
143
|
+
|
|
144
|
+
Shows threshold validation results:
|
|
145
|
+
|
|
146
|
+
- Threshold condition (e.g., `p(95)<1000`, `rate==0.00`)
|
|
147
|
+
- Actual value achieved
|
|
148
|
+
- Pass/Fail status with color coding
|
|
149
|
+
|
|
150
|
+
### 📝 Testing it out locally
|
|
151
|
+
|
|
152
|
+
Ideally have an empty directory named `reports`.
|
|
153
|
+
|
|
154
|
+
## Running Tests
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npm test
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## API Reference
|
|
161
|
+
|
|
162
|
+
### `htmlReport(data, options)`
|
|
163
|
+
|
|
164
|
+
Generates and returns a complete HTML document as a string.
|
|
165
|
+
|
|
166
|
+
**Parameters:**
|
|
167
|
+
|
|
168
|
+
- `data` (Object): The k6 test results data object containing metrics, checks, and thresholds
|
|
169
|
+
- `options` (Object): Configuration options
|
|
170
|
+
- `title` (string): Main report title - defaults to current timestamp
|
|
171
|
+
- `subtitle` (string): Subtitle or endpoint description
|
|
172
|
+
- `httpMethod` (string): HTTP method used (GET, POST, PUT, DELETE, etc.)
|
|
173
|
+
- `additionalInfo` (Object): Key-value pairs of custom test information
|
|
174
|
+
- `debug` (boolean): If true, logs raw k6 data to console
|
|
175
|
+
|
|
176
|
+
**Returns:**
|
|
177
|
+
|
|
178
|
+
- (string): Complete HTML document
|
|
179
|
+
|
|
180
|
+
## License
|
|
181
|
+
|
|
182
|
+
MIT License. See LICENSE file for details.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|