monocart-reporter 2.9.17 → 2.9.19
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/lib/default/options.js +4 -1
- package/lib/generate-data.js +13 -10
- package/lib/generate-report.js +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +7 -4
- package/lib/merge-data.js +2 -2
- package/lib/packages/monocart-reporter-assets.js +2 -2
- package/lib/packages/monocart-reporter-vendor.js +9 -9
- package/lib/platform/share.js +53 -0
- package/lib/utils/pie.js +21 -7
- package/lib/utils/system.js +3 -3
- package/lib/utils/util.js +5 -0
- package/lib/visitor.js +29 -7
- package/package.json +15 -15
package/lib/default/options.js
CHANGED
|
@@ -25,9 +25,12 @@ module.exports = () => ({
|
|
|
25
25
|
// custom trace viewer url
|
|
26
26
|
traceViewerUrl: 'https://trace.playwright.dev/?trace={traceUrl}',
|
|
27
27
|
|
|
28
|
-
// timezone offset in minutes, GMT+0800 = -480
|
|
28
|
+
// timezone offset in minutes, For example: GMT+0800 = -480
|
|
29
29
|
timezoneOffset: 0,
|
|
30
30
|
|
|
31
|
+
// For example: en-US, zh-CN
|
|
32
|
+
locale: null,
|
|
33
|
+
|
|
31
34
|
// normal or exclude-idle
|
|
32
35
|
durationStrategy: null,
|
|
33
36
|
|
package/lib/generate-data.js
CHANGED
|
@@ -27,12 +27,6 @@ const artifactsHandler = async (visitor, reporterOptions) => {
|
|
|
27
27
|
return artifacts;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
const getReportDate = (timestampStart, timezoneOffset = 0) => {
|
|
31
|
-
// in minutes
|
|
32
|
-
const offset = Util.toNum(timezoneOffset);
|
|
33
|
-
return timestampStart + offset * 60 * 1000;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
30
|
const generateMermaid = (options) => {
|
|
37
31
|
const mermaidOptions = options.mermaid;
|
|
38
32
|
if (mermaidOptions) {
|
|
@@ -128,16 +122,21 @@ const generateData = async (results) => {
|
|
|
128
122
|
system.outputFile = Util.relativePath(outputFile);
|
|
129
123
|
system.outputDir = Util.relativePath(outputDir);
|
|
130
124
|
|
|
125
|
+
const timezone = new Date().getTimezoneOffset() / 60;
|
|
126
|
+
const timezoneOffset = options.timezoneOffset;
|
|
127
|
+
const locale = options.locale;
|
|
128
|
+
|
|
131
129
|
// add one last tick before end time
|
|
132
|
-
const
|
|
130
|
+
const timestamp = Util.addTimezoneOffset(Date.now(), timezoneOffset);
|
|
131
|
+
const tickInfo = await getTickInfo(timestamp);
|
|
133
132
|
system.ticks.push(tickInfo);
|
|
134
133
|
|
|
135
134
|
// let start timestamp as date
|
|
136
|
-
const date =
|
|
137
|
-
const dateH =
|
|
135
|
+
const date = system.timestampStart;
|
|
136
|
+
const dateH = Util.dateFormat(date, locale);
|
|
138
137
|
|
|
139
138
|
// end timestamp for duration
|
|
140
|
-
system.timestampEnd =
|
|
139
|
+
system.timestampEnd = timestamp;
|
|
141
140
|
const duration = system.timestampEnd - system.timestampStart;
|
|
142
141
|
const durationH = Util.TF(duration);
|
|
143
142
|
|
|
@@ -151,6 +150,10 @@ const generateData = async (results) => {
|
|
|
151
150
|
duration,
|
|
152
151
|
durationH,
|
|
153
152
|
|
|
153
|
+
timezone,
|
|
154
|
+
timezoneOffset,
|
|
155
|
+
locale,
|
|
156
|
+
|
|
154
157
|
// for current process, like merge process
|
|
155
158
|
cwd,
|
|
156
159
|
outputFile,
|
package/lib/generate-report.js
CHANGED
|
@@ -210,7 +210,7 @@ const showTestResults = (reportData) => {
|
|
|
210
210
|
value: `v${system.playwright}`
|
|
211
211
|
}, {
|
|
212
212
|
name: 'Date',
|
|
213
|
-
value:
|
|
213
|
+
value: Util.dateFormat(reportData.date, reportData.locale)
|
|
214
214
|
}, {
|
|
215
215
|
name: 'Duration',
|
|
216
216
|
value: Util.TF(reportData.duration)
|
package/lib/index.d.ts
CHANGED
|
@@ -93,6 +93,9 @@ export type MonocartReporterOptions = {
|
|
|
93
93
|
/** timezone offset in minutes, For example: GMT+0800 = -480 */
|
|
94
94
|
timezoneOffset?: number;
|
|
95
95
|
|
|
96
|
+
/** For example: en-US, zh-CN */
|
|
97
|
+
locale?: string;
|
|
98
|
+
|
|
96
99
|
/** normal or exclude-idle */
|
|
97
100
|
durationStrategy?: 'normal' | 'exclude-idle',
|
|
98
101
|
|
package/lib/index.js
CHANGED
|
@@ -45,12 +45,14 @@ class MonocartReporter {
|
|
|
45
45
|
... userOptions
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
+
this.options.timezoneOffset = Util.toNum(this.options.timezoneOffset);
|
|
49
|
+
|
|
48
50
|
Util.initLoggingLevel(this.options.logging, 'reporter');
|
|
49
51
|
|
|
50
52
|
this.testMap = new Map();
|
|
51
53
|
|
|
52
54
|
this.system = getSystemInfo();
|
|
53
|
-
this.system.timestampStart = timestampStart;
|
|
55
|
+
this.system.timestampStart = Util.addTimezoneOffset(timestampStart, this.options.timezoneOffset);
|
|
54
56
|
this.system.ticks = [];
|
|
55
57
|
|
|
56
58
|
this.tickTime = this.options.tickTime || 1000;
|
|
@@ -142,7 +144,8 @@ class MonocartReporter {
|
|
|
142
144
|
|
|
143
145
|
tickStart() {
|
|
144
146
|
this.tick_time_id = setTimeout(async () => {
|
|
145
|
-
const
|
|
147
|
+
const timestamp = Util.addTimezoneOffset(Date.now(), this.options.timezoneOffset);
|
|
148
|
+
const tickInfo = await getTickInfo(timestamp);
|
|
146
149
|
this.system.ticks.push(tickInfo);
|
|
147
150
|
this.tickStart();
|
|
148
151
|
}, this.tickTime);
|
|
@@ -203,7 +206,7 @@ class MonocartReporter {
|
|
|
203
206
|
if (!test.timestamps) {
|
|
204
207
|
test.timestamps = [];
|
|
205
208
|
}
|
|
206
|
-
test.timestamps.push(Date.now());
|
|
209
|
+
test.timestamps.push(Util.addTimezoneOffset(Date.now(), this.options.timezoneOffset));
|
|
207
210
|
|
|
208
211
|
// keep logs here with order
|
|
209
212
|
// result stderr and stdout without order
|
|
@@ -247,7 +250,7 @@ class MonocartReporter {
|
|
|
247
250
|
}
|
|
248
251
|
|
|
249
252
|
// timestamps
|
|
250
|
-
test.timestamps.push(Date.now());
|
|
253
|
+
test.timestamps.push(Util.addTimezoneOffset(Date.now(), this.options.timezoneOffset));
|
|
251
254
|
|
|
252
255
|
}
|
|
253
256
|
|
package/lib/merge-data.js
CHANGED
|
@@ -326,7 +326,7 @@ const mergeDataList = async (dataList, options) => {
|
|
|
326
326
|
};
|
|
327
327
|
|
|
328
328
|
// merge new options
|
|
329
|
-
['traceViewerUrl', 'mermaid'].forEach((k) => {
|
|
329
|
+
['traceViewerUrl', 'mermaid', 'timezoneOffset', 'locale'].forEach((k) => {
|
|
330
330
|
if (Util.hasOwn(options, k)) {
|
|
331
331
|
mergedData[k] = options[k];
|
|
332
332
|
}
|
|
@@ -336,7 +336,7 @@ const mergeDataList = async (dataList, options) => {
|
|
|
336
336
|
const reportLogo = options.logo || mergedData.logo;
|
|
337
337
|
|
|
338
338
|
const date = Math.min.apply(null, startDates);
|
|
339
|
-
const dateH =
|
|
339
|
+
const dateH = Util.dateFormat(date, mergedData.locale);
|
|
340
340
|
|
|
341
341
|
const duration = Util.getDuration(dateRanges, options.durationStrategy);
|
|
342
342
|
const durationH = Util.TF(duration);
|