monocart-reporter 2.9.9 → 2.9.10
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 +21 -6
- package/lib/common.js +6 -1
- package/lib/default/summary.js +16 -10
- package/lib/generate-data.js +1 -1
- 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
|
|
@@ -846,7 +852,7 @@ Attach a network report with API `attachNetworkReport(har, testInfo)`. Arguments
|
|
|
846
852
|
- `har` HAR path (String) or HAR file buffer (Buffer). see [HAR 1.2 Spec](http://www.softwareishard.com/blog/har-12-spec/)
|
|
847
853
|
- `testInfo` see [TestInfo](https://playwright.dev/docs/api/class-testinfo)
|
|
848
854
|
|
|
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
|
|
855
|
+
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
856
|
|
|
851
857
|
```js
|
|
852
858
|
const fs = require('fs');
|
|
@@ -912,7 +918,7 @@ test('finally, attach HAR', async () => {
|
|
|
912
918
|
await attachNetworkReport(harPath, test.info());
|
|
913
919
|
});
|
|
914
920
|
```
|
|
915
|
-
Preview [Network HTML Report](https://cenfun.github.io/monocart-reporter
|
|
921
|
+
Preview [Network HTML Report](https://cenfun.github.io/monocart-reporter/#page=report)
|
|
916
922
|
|
|
917
923
|
## Global State Management
|
|
918
924
|
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.
|
|
@@ -1149,10 +1155,19 @@ module.exports = {
|
|
|
1149
1155
|
## onData hook
|
|
1150
1156
|
The `onData` function will be executed after report data generated (before `onEnd`).
|
|
1151
1157
|
```js
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1158
|
+
// playwright.config.js
|
|
1159
|
+
module.exports = {
|
|
1160
|
+
reporter: [
|
|
1161
|
+
['monocart-reporter', {
|
|
1162
|
+
name: "My Test Report",
|
|
1163
|
+
outputFile: './monocart-report/index.html',
|
|
1164
|
+
onData: (reportData) => {
|
|
1165
|
+
// console.log('onData', reportData);
|
|
1166
|
+
reportData.name = 'My New Report Name';
|
|
1167
|
+
}
|
|
1168
|
+
}]
|
|
1169
|
+
]
|
|
1170
|
+
};
|
|
1156
1171
|
```
|
|
1157
1172
|
|
|
1158
1173
|
## 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/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;
|