monocart-reporter 1.7.9 → 1.7.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 +3 -0
- package/lib/default/options.js +3 -0
- package/lib/generate-data.js +9 -3
- package/lib/index.d.ts +6 -0
- package/lib/index.js +4 -1
- package/lib/index.mjs +1 -0
- package/lib/platform/share.js +33 -0
- package/lib/plugins/coverage/coverage.js +2 -2
- package/lib/runtime/monocart-common.js +1 -1
- package/lib/runtime/monocart-reporter.js +1 -1
- package/lib/runtime/monocart-vendor.js +8 -8
- package/lib/visitor.js +36 -8
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -129,6 +129,9 @@ Separated metadata file (Already included in the above HTML and compressed, it c
|
|
|
129
129
|
// logging levels: off, error, info, debug
|
|
130
130
|
logging: 'info',
|
|
131
131
|
|
|
132
|
+
// timezone offset in minutes, GMT+0800 = -480
|
|
133
|
+
timezoneOffset: 0,
|
|
134
|
+
|
|
132
135
|
// global coverage settings for addCoverageReport API
|
|
133
136
|
coverage: null,
|
|
134
137
|
// coverage: {
|
package/lib/default/options.js
CHANGED
package/lib/generate-data.js
CHANGED
|
@@ -4,7 +4,7 @@ const Util = require('./utils/util.js');
|
|
|
4
4
|
const { getTickInfo } = require('./utils/system.js');
|
|
5
5
|
const Visitor = require('./visitor.js');
|
|
6
6
|
const { calculateSummary } = require('./common.js');
|
|
7
|
-
const {
|
|
7
|
+
const { addGlobalCoverageReport } = require('./plugins/coverage/coverage.js');
|
|
8
8
|
const version = require('../package.json').version;
|
|
9
9
|
|
|
10
10
|
const getReportName = (options, config, metadata) => {
|
|
@@ -20,12 +20,18 @@ const artifactsHandler = async (visitor, options) => {
|
|
|
20
20
|
// global artifacts
|
|
21
21
|
const { coverage } = visitor.artifactDataMap;
|
|
22
22
|
if (coverage) {
|
|
23
|
-
const report = await
|
|
23
|
+
const report = await addGlobalCoverageReport(coverage, options);
|
|
24
24
|
artifacts.push(report);
|
|
25
25
|
}
|
|
26
26
|
return artifacts;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
+
const getReportDate = (timestampStart, timezoneOffset = 0) => {
|
|
30
|
+
// in minutes
|
|
31
|
+
const offset = Util.toNum(timezoneOffset);
|
|
32
|
+
return timestampStart + offset * 60 * 1000;
|
|
33
|
+
};
|
|
34
|
+
|
|
29
35
|
const generateData = async (results) => {
|
|
30
36
|
|
|
31
37
|
Util.logInfo('generating report data ...');
|
|
@@ -103,7 +109,7 @@ const generateData = async (results) => {
|
|
|
103
109
|
system.ticks.push(tickInfo);
|
|
104
110
|
|
|
105
111
|
// let start timestamp as date
|
|
106
|
-
const date = system.timestampStart;
|
|
112
|
+
const date = getReportDate(system.timestampStart, options.timezoneOffset);
|
|
107
113
|
const dateH = new Date(date).toLocaleString();
|
|
108
114
|
|
|
109
115
|
// end timestamp for duration
|
package/lib/index.d.ts
CHANGED
|
@@ -32,6 +32,12 @@ export function addCoverageReport(
|
|
|
32
32
|
testInfo: TestInfo
|
|
33
33
|
): Promise<any | void>;
|
|
34
34
|
|
|
35
|
+
// exporting for other test runner (issue #61)
|
|
36
|
+
export function addGlobalCoverageReport(
|
|
37
|
+
dataList: any[],
|
|
38
|
+
reporterOptions: any
|
|
39
|
+
): Promise<any>;
|
|
40
|
+
|
|
35
41
|
export type CoverageReportOptions = {
|
|
36
42
|
|
|
37
43
|
title?: string,
|
package/lib/index.js
CHANGED
|
@@ -7,7 +7,9 @@ const { getTrends } = require('./common.js');
|
|
|
7
7
|
|
|
8
8
|
const merge = require('./merge-data.js');
|
|
9
9
|
const { attachAuditReport } = require('./plugins/audit/audit.js');
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
addCoverageReport, addGlobalCoverageReport, attachCoverageReport
|
|
12
|
+
} = require('./plugins/coverage/coverage.js');
|
|
11
13
|
const { attachNetworkReport } = require('./plugins/network/network.js');
|
|
12
14
|
|
|
13
15
|
const { createStateServer, useState } = require('./plugins/state/state.js');
|
|
@@ -22,6 +24,7 @@ class Reporter {
|
|
|
22
24
|
static attachAuditReport = attachAuditReport;
|
|
23
25
|
|
|
24
26
|
static addCoverageReport = addCoverageReport;
|
|
27
|
+
static addGlobalCoverageReport = addGlobalCoverageReport;
|
|
25
28
|
static attachCoverageReport = attachCoverageReport;
|
|
26
29
|
|
|
27
30
|
static attachNetworkReport = attachNetworkReport;
|
package/lib/index.mjs
CHANGED
|
@@ -8,6 +8,7 @@ export const merge = MonocartReporter.merge;
|
|
|
8
8
|
export const attachAuditReport = MonocartReporter.attachAuditReport;
|
|
9
9
|
|
|
10
10
|
export const addCoverageReport = MonocartReporter.addCoverageReport;
|
|
11
|
+
export const addGlobalCoverageReport = MonocartReporter.addGlobalCoverageReport;
|
|
11
12
|
export const attachCoverageReport = MonocartReporter.attachCoverageReport;
|
|
12
13
|
|
|
13
14
|
export const attachNetworkReport = MonocartReporter.attachNetworkReport;
|
package/lib/platform/share.js
CHANGED
|
@@ -194,6 +194,39 @@ const Util = {
|
|
|
194
194
|
return 'high';
|
|
195
195
|
},
|
|
196
196
|
|
|
197
|
+
isJsonType(contentType) {
|
|
198
|
+
if (contentType) {
|
|
199
|
+
if (contentType === 'application/json' || contentType === 'json') {
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
isMarkdownType(contentType) {
|
|
207
|
+
if (contentType) {
|
|
208
|
+
if (contentType === 'text/markdown' || contentType === 'markdown') {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return false;
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
isTextType(contentType) {
|
|
216
|
+
if (contentType) {
|
|
217
|
+
if (contentType.startsWith('text')) {
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
if (Util.isMarkdownType(contentType)) {
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
if (Util.isJsonType(contentType)) {
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return false;
|
|
228
|
+
},
|
|
229
|
+
|
|
197
230
|
// =============================================================================
|
|
198
231
|
// svg
|
|
199
232
|
|
|
@@ -250,7 +250,7 @@ const getGlobalCoverageData = async (dataList, options) => {
|
|
|
250
250
|
};
|
|
251
251
|
|
|
252
252
|
// global coverage report, run different process with addCoverageReport
|
|
253
|
-
const
|
|
253
|
+
const addGlobalCoverageReport = async (dataList, reporterOptions) => {
|
|
254
254
|
|
|
255
255
|
Util.logInfo('generating global coverage report ...');
|
|
256
256
|
|
|
@@ -306,6 +306,6 @@ const generateGlobalCoverageReport = async (dataList, reporterOptions) => {
|
|
|
306
306
|
|
|
307
307
|
module.exports = {
|
|
308
308
|
addCoverageReport,
|
|
309
|
-
|
|
309
|
+
addGlobalCoverageReport,
|
|
310
310
|
attachCoverageReport
|
|
311
311
|
};
|