monocart-reporter 2.9.7 → 2.9.9
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 +10 -0
- package/lib/index.js +25 -2
- package/lib/packages/monocart-reporter-assets.js +2 -2
- package/lib/packages/monocart-reporter-vendor.js +22 -23
- package/lib/utils/util.js +9 -8
- package/package.json +89 -89
package/README.md
CHANGED
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
- [Send and Receive Messages between Processes](#send-and-receive-messages-between-processes)
|
|
49
49
|
* [Merge Shard Reports](#merge-shard-reports)
|
|
50
50
|
* [onEnd Hook](#onend-hook)
|
|
51
|
+
* [onData Hook](#ondata-hook)
|
|
51
52
|
* [Integration Examples](#integration-examples)
|
|
52
53
|
* [Contributing](#contributing)
|
|
53
54
|
* [Changelog](CHANGELOG.md)
|
|
@@ -1145,6 +1146,15 @@ module.exports = {
|
|
|
1145
1146
|
};
|
|
1146
1147
|
```
|
|
1147
1148
|
|
|
1149
|
+
## onData hook
|
|
1150
|
+
The `onData` function will be executed after report data generated (before `onEnd`).
|
|
1151
|
+
```js
|
|
1152
|
+
onData: (reportData) => {
|
|
1153
|
+
// console.log('onData', reportData);
|
|
1154
|
+
reportData.name = 'My Report Name';
|
|
1155
|
+
}
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1148
1158
|
## Integration Examples
|
|
1149
1159
|
By using the `onEnd` hook, we can integrate Playwright report with any other tools, such as:
|
|
1150
1160
|
- [Email](https://github.com/cenfun/playwright-reporter-integrations/tree/main/send-email)
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
1
2
|
const path = require('path');
|
|
2
3
|
const EC = require('eight-colors');
|
|
3
4
|
const { getSystemInfo, getTickInfo } = require('./utils/system.js');
|
|
@@ -95,8 +96,30 @@ class MonocartReporter {
|
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
cleanOutputDir() {
|
|
98
|
-
|
|
99
|
-
//
|
|
99
|
+
|
|
100
|
+
// after trends
|
|
101
|
+
const outputDir = this.options.outputDir;
|
|
102
|
+
if (!fs.existsSync(outputDir)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const list = fs.readdirSync(outputDir);
|
|
107
|
+
if (!list.length) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
Util.logInfo('clean output dir ...');
|
|
112
|
+
for (const item of list) {
|
|
113
|
+
|
|
114
|
+
// console.log('remove', item);
|
|
115
|
+
try {
|
|
116
|
+
Util.rmSync(path.resolve(outputDir, item));
|
|
117
|
+
} catch (e) {
|
|
118
|
+
// console.log('=======================', e);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
|
|
100
123
|
}
|
|
101
124
|
|
|
102
125
|
// ==========================================================================
|