k6-modern-reporter 1.0.1 → 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.
- package/README.md +60 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,14 +44,69 @@ Add the following import like this in any ts file:
|
|
|
44
44
|
import { htmlReport } from 'https://raw.githubusercontent.com/Samin005/k6-modern-reporter/refs/heads/main/k6-modern-reporter.js';
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
### Using NPM
|
|
47
|
+
### Using NPM and esbuild
|
|
48
48
|
|
|
49
49
|
1. Run `npm i k6-modern-reporter` into your k6 project
|
|
50
50
|
2. Import `htmlReport` in your script:
|
|
51
51
|
|
|
52
|
-
```
|
|
53
|
-
import { htmlReport } from 'k6-modern-reporter';
|
|
54
|
-
```
|
|
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
|
+
```
|
|
55
110
|
|
|
56
111
|
## Usage
|
|
57
112
|
|
|
@@ -161,9 +216,7 @@ Shows threshold validation results:
|
|
|
161
216
|
|
|
162
217
|
### 📝 Testing it out locally
|
|
163
218
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
## Running Tests
|
|
219
|
+
Clone the repo and run:
|
|
167
220
|
|
|
168
221
|
```bash
|
|
169
222
|
npm test
|