monocart-reporter 2.9.9 → 2.9.11
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 +38 -8
- package/lib/common.js +6 -1
- package/lib/default/options.js +3 -0
- package/lib/default/summary.js +16 -10
- package/lib/generate-data.js +2 -1
- package/lib/index.d.ts +6 -0
- package/lib/merge-data.js +2 -0
- package/lib/packages/monocart-reporter-assets.js +1 -1
- package/lib/packages/monocart-reporter-vendor.js +15 -15
- package/lib/utils/pie.js +2 -2
- package/package.json +89 -89
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* [Install](#install)
|
|
20
20
|
* [Playwright Config](#playwright-config)
|
|
21
21
|
* [Examples](#examples)
|
|
22
|
+
* [Tutorial](#tutorial)
|
|
22
23
|
* [Output](#output)
|
|
23
24
|
* [Reporter Options](#reporter-options)
|
|
24
25
|
* [View Trace Online](#view-trace-online)
|
|
@@ -88,6 +89,11 @@ Playwright Docs [https://playwright.dev/docs/test-reporters](https://playwright.
|
|
|
88
89
|
- [monocart-reporter-examples](https://github.com/cenfun/monocart-reporter-examples)
|
|
89
90
|
- [playwright-reporter-integrations](https://github.com/cenfun/playwright-reporter-integrations)
|
|
90
91
|
|
|
92
|
+
## Tutorial
|
|
93
|
+
- [Playwright + Monocart = Next-Level Custom Reports! | Step-by-Step Tutorial!](https://www.youtube.com/watch?v=8Ae-lkFAG5Q)
|
|
94
|
+
- [Optimising Playwright Reporting Through Monocart](https://engineering.kablamo.com.au/posts/2024/optimising-playwright-reporting-through-monocart/)
|
|
95
|
+
- [Leveraging Playwright's Powerful End-to-End Testing, MongoDB, Data Fixtures for Live Execution Insights](https://www.linkedin.com/pulse/leveraging-playwrights-powerful-end-to-end-testing-data-kandukuri-ak6ac/)
|
|
96
|
+
|
|
91
97
|
## Output
|
|
92
98
|
- path-to/your-filename.html
|
|
93
99
|
Single HTML file (data compressed), easy to transfer/deploy or open directly anywhere
|
|
@@ -95,7 +101,21 @@ Single HTML file (data compressed), easy to transfer/deploy or open directly any
|
|
|
95
101
|
- path-to/your-filename.json (requires option `json` is true)
|
|
96
102
|
Separated data file which can be used for debugging or data provider (It's included in the above HTML and compressed).
|
|
97
103
|
- path-to/your-filename.zip (requires option `zip` is true)
|
|
98
|
-
Zip file for merging reports
|
|
104
|
+
Zip file for merging reports
|
|
105
|
+
- custom zip options
|
|
106
|
+
```js
|
|
107
|
+
{
|
|
108
|
+
// zip: true,
|
|
109
|
+
// zip: `${YourOutputDir}/monocart-shard-${your-shard-number}.zip`,
|
|
110
|
+
zip: {
|
|
111
|
+
// custom zip `outputFile`, defaults to reporter `outputFile` but uses `.zip` extension
|
|
112
|
+
outputFile: `${YourOutputDir}/monocart-shard-${your-shard-number}.zip`,
|
|
113
|
+
// clean other report files except for zip file, defaults to false
|
|
114
|
+
clean: true
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
99
119
|
|
|
100
120
|
## Reporter Options
|
|
101
121
|
- Default options: [lib/default/options.js](./lib/default/options.js)
|
|
@@ -846,7 +866,7 @@ Attach a network report with API `attachNetworkReport(har, testInfo)`. Arguments
|
|
|
846
866
|
- `har` HAR path (String) or HAR file buffer (Buffer). see [HAR 1.2 Spec](http://www.softwareishard.com/blog/har-12-spec/)
|
|
847
867
|
- `testInfo` see [TestInfo](https://playwright.dev/docs/api/class-testinfo)
|
|
848
868
|
|
|
849
|
-
Generate HAR with `recordHar` option in browser.newContext() (see example: [report-network.spec.js](https://github.com/cenfun/monocart-reporter/blob/main/tests/report-network/report-network.spec.js) preview [report](https://cenfun.github.io/monocart-reporter
|
|
869
|
+
Generate HAR with `recordHar` option in browser.newContext() (see example: [report-network.spec.js](https://github.com/cenfun/monocart-reporter/blob/main/tests/report-network/report-network.spec.js) preview [report](https://cenfun.github.io/monocart-reporter/#page=report))
|
|
850
870
|
|
|
851
871
|
```js
|
|
852
872
|
const fs = require('fs');
|
|
@@ -912,7 +932,7 @@ test('finally, attach HAR', async () => {
|
|
|
912
932
|
await attachNetworkReport(harPath, test.info());
|
|
913
933
|
});
|
|
914
934
|
```
|
|
915
|
-
Preview [Network HTML Report](https://cenfun.github.io/monocart-reporter
|
|
935
|
+
Preview [Network HTML Report](https://cenfun.github.io/monocart-reporter/#page=report)
|
|
916
936
|
|
|
917
937
|
## Global State Management
|
|
918
938
|
When tests are executed in [isolation](https://playwright.dev/docs/browser-contexts) mode, the reporter and each test may run in a different process, they cannot share data with each other. we can start a local WebSocket server to serve the global data, and read/write the global data with `useState` API from a test.
|
|
@@ -1030,7 +1050,7 @@ const reportDataList = [
|
|
|
1030
1050
|
'path-to/shard2/index.json',
|
|
1031
1051
|
'path-to/shard3/index.json'
|
|
1032
1052
|
|
|
1033
|
-
// Or load zip file directly if the output files is zipped
|
|
1053
|
+
// Or load zip file directly if the output files is zipped with option `zip` is true
|
|
1034
1054
|
// 'path-to/shard1/index.zip',
|
|
1035
1055
|
// 'path-to/shard2/index.zip',
|
|
1036
1056
|
// 'path-to/shard3/index.zip'
|
|
@@ -1044,6 +1064,7 @@ await merge(reportDataList, {
|
|
|
1044
1064
|
}
|
|
1045
1065
|
});
|
|
1046
1066
|
```
|
|
1067
|
+
see [Output](#output) for `zip` options
|
|
1047
1068
|
|
|
1048
1069
|
> Note: The coverage reports will be merged automatically if we specify the `raw` report in coverage options:
|
|
1049
1070
|
```js
|
|
@@ -1149,10 +1170,19 @@ module.exports = {
|
|
|
1149
1170
|
## onData hook
|
|
1150
1171
|
The `onData` function will be executed after report data generated (before `onEnd`).
|
|
1151
1172
|
```js
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1173
|
+
// playwright.config.js
|
|
1174
|
+
module.exports = {
|
|
1175
|
+
reporter: [
|
|
1176
|
+
['monocart-reporter', {
|
|
1177
|
+
name: "My Test Report",
|
|
1178
|
+
outputFile: './monocart-report/index.html',
|
|
1179
|
+
onData: (reportData) => {
|
|
1180
|
+
// console.log('onData', reportData);
|
|
1181
|
+
reportData.name = 'My New Report Name';
|
|
1182
|
+
}
|
|
1183
|
+
}]
|
|
1184
|
+
]
|
|
1185
|
+
};
|
|
1156
1186
|
```
|
|
1157
1187
|
|
|
1158
1188
|
## Integration Examples
|
package/lib/common.js
CHANGED
|
@@ -230,8 +230,13 @@ const getTrends = async (input) => {
|
|
|
230
230
|
return [];
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
// filter with one year ago
|
|
234
|
+
const date = new Date();
|
|
235
|
+
const oneYearAgo = date.setFullYear(date.getFullYear() - 1);
|
|
236
|
+
|
|
233
237
|
// copy previous trends
|
|
234
|
-
const trends = [].concat(data.trends || []);
|
|
238
|
+
const trends = [].concat(data.trends || []).filter((it) => it.date > oneYearAgo);
|
|
239
|
+
|
|
235
240
|
trends.push(Util.getCurrentTrendInfo(data));
|
|
236
241
|
|
|
237
242
|
return trends;
|
package/lib/default/options.js
CHANGED
package/lib/default/summary.js
CHANGED
|
@@ -4,10 +4,10 @@ module.exports = () => ({
|
|
|
4
4
|
value: 0,
|
|
5
5
|
nav: true
|
|
6
6
|
},
|
|
7
|
-
|
|
8
|
-
name: '
|
|
7
|
+
failed: {
|
|
8
|
+
name: 'Failed',
|
|
9
9
|
value: 0,
|
|
10
|
-
color: '
|
|
10
|
+
color: '#d00',
|
|
11
11
|
nav: true
|
|
12
12
|
},
|
|
13
13
|
flaky: {
|
|
@@ -22,10 +22,10 @@ module.exports = () => ({
|
|
|
22
22
|
color: 'gray',
|
|
23
23
|
nav: true
|
|
24
24
|
},
|
|
25
|
-
|
|
26
|
-
name: '
|
|
25
|
+
passed: {
|
|
26
|
+
name: 'Passed',
|
|
27
27
|
value: 0,
|
|
28
|
-
color: '
|
|
28
|
+
color: 'green',
|
|
29
29
|
nav: true
|
|
30
30
|
},
|
|
31
31
|
|
|
@@ -60,21 +60,27 @@ module.exports = () => ({
|
|
|
60
60
|
value: 0
|
|
61
61
|
},
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
name: '
|
|
63
|
+
errors: {
|
|
64
|
+
name: 'Errors',
|
|
65
|
+
icon: 'error',
|
|
65
66
|
value: 0
|
|
66
67
|
},
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
name: '
|
|
69
|
+
retries: {
|
|
70
|
+
name: 'Retries',
|
|
71
|
+
icon: 'retry',
|
|
70
72
|
value: 0
|
|
71
73
|
},
|
|
74
|
+
|
|
72
75
|
logs: {
|
|
73
76
|
name: 'Logs',
|
|
77
|
+
icon: 'log',
|
|
74
78
|
value: 0
|
|
75
79
|
},
|
|
80
|
+
|
|
76
81
|
attachments: {
|
|
77
82
|
name: 'Attachments',
|
|
83
|
+
icon: 'attachment',
|
|
78
84
|
value: 0
|
|
79
85
|
}
|
|
80
86
|
});
|
package/lib/generate-data.js
CHANGED
|
@@ -97,7 +97,7 @@ const generateData = async (results) => {
|
|
|
97
97
|
|
|
98
98
|
// suite and case types
|
|
99
99
|
data.suiteTypes = ['project', 'file', 'describe', 'shard'];
|
|
100
|
-
data.caseTypes = ['
|
|
100
|
+
data.caseTypes = ['failed', 'flaky', 'skipped', 'passed'];
|
|
101
101
|
data.traceViewerUrl = options.traceViewerUrl;
|
|
102
102
|
data.mermaid = generateMermaid(options);
|
|
103
103
|
data.groupOptions = options.groupOptions;
|
|
@@ -144,6 +144,7 @@ const generateData = async (results) => {
|
|
|
144
144
|
const reportData = {
|
|
145
145
|
// for report title
|
|
146
146
|
name: reportName,
|
|
147
|
+
logo: options.logo,
|
|
147
148
|
|
|
148
149
|
date,
|
|
149
150
|
dateH,
|
package/lib/index.d.ts
CHANGED
|
@@ -51,6 +51,12 @@ export type MonocartReporterOptions = {
|
|
|
51
51
|
/** the report name */
|
|
52
52
|
name?: string;
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* image url, supports data url:
|
|
56
|
+
* `data:image/png;base64,${fs.readFileSync('path-to/your-logo.png').toString('base64')}`
|
|
57
|
+
*/
|
|
58
|
+
logo?: string;
|
|
59
|
+
|
|
54
60
|
/** the output file path (relative process.cwd) */
|
|
55
61
|
outputFile?: string;
|
|
56
62
|
|
package/lib/merge-data.js
CHANGED
|
@@ -333,6 +333,7 @@ const mergeDataList = async (dataList, options) => {
|
|
|
333
333
|
});
|
|
334
334
|
|
|
335
335
|
const reportName = options.name || mergedData.name;
|
|
336
|
+
const reportLogo = options.logo || mergedData.logo;
|
|
336
337
|
|
|
337
338
|
const date = Math.min.apply(null, startDates);
|
|
338
339
|
const dateH = new Date(date).toLocaleString();
|
|
@@ -342,6 +343,7 @@ const mergeDataList = async (dataList, options) => {
|
|
|
342
343
|
|
|
343
344
|
Object.assign(mergedData, {
|
|
344
345
|
name: reportName,
|
|
346
|
+
logo: reportLogo,
|
|
345
347
|
|
|
346
348
|
date,
|
|
347
349
|
dateH,
|