k6-modern-reporter 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/README.md +72 -7
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -35,12 +35,78 @@ A modern, beautiful HTML report generator for k6 performance tests with an inter
35
35
 
36
36
  ## Installation
37
37
 
38
+ ### Direct Import Raw
39
+
40
+ Add the following import like this in any ts file:
41
+
42
+ ```typescript
43
+ // @ts-ignore
44
+ import { htmlReport } from 'https://raw.githubusercontent.com/Samin005/k6-modern-reporter/refs/heads/main/k6-modern-reporter.js';
45
+ ```
46
+
47
+ ### Using NPM and esbuild
48
+
38
49
  1. Run `npm i k6-modern-reporter` into your k6 project
39
50
  2. Import `htmlReport` in your script:
40
51
 
41
- ```javascript
42
- import { htmlReport } from 'k6-modern-reporter';
43
- ```
52
+ ```typescript
53
+ import { htmlReport } from 'k6-modern-reporter';
54
+ ```
55
+
56
+ 3. k6 does not allow npm packages (since it uses go), so we have to create a bundle of the file if we want to run it. For example, let's say we have a `test.ts` (or `test.js`, works for both .ts and .js) with k6 tests:
57
+
58
+ ```typescript
59
+ import http from 'k6/http';
60
+ import { htmlReport } from 'k6-modern-reporter';
61
+
62
+ export const options = {
63
+ scenarios: {
64
+ shared_iteration: {
65
+ executor: 'shared-iterations',
66
+ vus: 50,
67
+ iterations: 100,
68
+ maxDuration: '60s',
69
+ }
70
+ }
71
+ };
72
+
73
+ export default function () {
74
+ const response = http.get("https://httpbin.org/get");
75
+ }
76
+
77
+ // Generate the HTML report
78
+ export function handleSummary(data) {
79
+ const reportFileName = `./test-report-${new Date().toJSON().split(':').join('-')}.html`;
80
+ return {
81
+ [reportFileName]: htmlReport(data)
82
+ };
83
+ }
84
+ ```
85
+
86
+ 4. We have to create a bundle of the file `test.bundle.js` with esbuild.
87
+
88
+ Windows Powershell:
89
+
90
+ ```powershell
91
+ npx esbuild test.ts --bundle --outfile=dist/test.bundle.js --format=esm --external:k6 --external:"k6/*"
92
+ ```
93
+
94
+ Mac/Linux:
95
+
96
+ ```bash
97
+ npx esbuild test.ts \
98
+ --bundle \
99
+ --outfile=dist/test.bundle.js \
100
+ --format=esm \
101
+ --external:k6 \
102
+ --external:k6/*
103
+ ```
104
+
105
+ 5. Now run the bundle file with k6:
106
+
107
+ ```bash
108
+ k6 run dist/test.bundle.js
109
+ ```
44
110
 
45
111
  ## Usage
46
112
 
@@ -51,7 +117,8 @@ Example of a k6 test script:
51
117
  ```typescript
52
118
  import http from 'k6/http';
53
119
  import { check } from 'k6';
54
- import { htmlReport } from 'k6-modern-reporter';
120
+ // @ts-ignore
121
+ import { htmlReport } from 'https://raw.githubusercontent.com/Samin005/k6-modern-reporter/refs/heads/main/k6-modern-reporter.js';
55
122
 
56
123
  export const options = {
57
124
  scenarios: {
@@ -149,9 +216,7 @@ Shows threshold validation results:
149
216
 
150
217
  ### 📝 Testing it out locally
151
218
 
152
- Ideally have an empty directory named `reports`.
153
-
154
- ## Running Tests
219
+ Clone the repo and run:
155
220
 
156
221
  ```bash
157
222
  npm test
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "k6-modern-reporter",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A modern reporter for k6",
5
5
  "main": "k6-modern-reporter.js",
6
6
  "scripts": {