monocart-reporter 2.1.0 → 2.2.0
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 +109 -203
- package/lib/default/options.js +4 -1
- package/lib/generate-report.js +2 -2
- package/lib/index.d.ts +5 -5
- package/lib/index.js +10 -12
- package/lib/packages/monocart-common.js +1 -1
- package/lib/packages/monocart-network.js +1 -1
- package/lib/packages/monocart-reporter-app.js +1 -0
- package/lib/packages/monocart-vendor.js +12 -19
- package/lib/platform/share.js +0 -1
- package/lib/plugins/comments.js +33 -34
- package/lib/visitor.js +6 -7
- package/package.json +7 -7
- package/lib/packages/monocart-reporter.js +0 -1
- package/lib/utils/parse-source.js +0 -19
package/lib/platform/share.js
CHANGED
package/lib/plugins/comments.js
CHANGED
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const Util = require('../utils/util.js');
|
|
3
|
-
const
|
|
3
|
+
const { Locator } = require('monocart-formatter/node');
|
|
4
4
|
|
|
5
5
|
const cacheMap = new Map();
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const emptyLines = [];
|
|
9
|
-
const reg = /\S/;
|
|
10
|
-
lines.forEach((text, i) => {
|
|
11
|
-
if (!reg.test(text)) {
|
|
12
|
-
emptyLines.push(i + 1);
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
return emptyLines;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const getFileComments = (sourcePath, options = {}) => {
|
|
7
|
+
const getFileComments = (sourcePath) => {
|
|
19
8
|
|
|
20
9
|
const map = new Map();
|
|
21
10
|
|
|
@@ -27,33 +16,43 @@ const getFileComments = (sourcePath, options = {}) => {
|
|
|
27
16
|
|
|
28
17
|
const source = fs.readFileSync(sourcePath).toString('utf-8');
|
|
29
18
|
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
const locator = new Locator(source);
|
|
20
|
+
|
|
21
|
+
const { comments, lines } = locator.lineParser;
|
|
22
|
+
|
|
23
|
+
// get empty lines, no value
|
|
24
|
+
lines.forEach((item) => {
|
|
25
|
+
if (item.blank) {
|
|
26
|
+
// 0-base
|
|
27
|
+
map.set(item.line + 1, {});
|
|
28
|
+
}
|
|
34
29
|
});
|
|
35
30
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
comments.forEach((item) => {
|
|
32
|
+
const {
|
|
33
|
+
start, end, text
|
|
34
|
+
} = item;
|
|
35
|
+
|
|
36
|
+
// using last line
|
|
37
|
+
// 1-base
|
|
38
|
+
const eLoc = locator.offsetToLocation(end);
|
|
39
|
+
map.set(eLoc.line, {
|
|
40
|
+
value: text
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// exists first line
|
|
44
|
+
if (map.has(1)) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
39
47
|
|
|
40
|
-
ast.comments.forEach((item) => {
|
|
41
48
|
// first line comments for file line 0
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
49
|
+
const sLoc = locator.offsetToLocation(start);
|
|
50
|
+
if (sLoc.line === 1) {
|
|
44
51
|
map.set(1, {
|
|
45
|
-
value:
|
|
52
|
+
value: text
|
|
46
53
|
});
|
|
47
54
|
}
|
|
48
|
-
map.set(item.loc.end.line, {
|
|
49
|
-
value: item.value
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
55
|
|
|
53
|
-
// get empty lines
|
|
54
|
-
const lines = source.split(Util.lineBreakPattern);
|
|
55
|
-
getEmptyLines(lines).forEach((line) => {
|
|
56
|
-
map.set(line, {});
|
|
57
56
|
});
|
|
58
57
|
|
|
59
58
|
return map;
|
|
@@ -91,7 +90,7 @@ const findComment = (line, map) => {
|
|
|
91
90
|
return findCommentAbove(line, map);
|
|
92
91
|
};
|
|
93
92
|
|
|
94
|
-
module.exports = (metadata
|
|
93
|
+
module.exports = (metadata) => {
|
|
95
94
|
const location = metadata.location;
|
|
96
95
|
if (!location) {
|
|
97
96
|
return;
|
|
@@ -104,7 +103,7 @@ module.exports = (metadata, parserOptions) => {
|
|
|
104
103
|
|
|
105
104
|
let map = cacheMap.get(location.file);
|
|
106
105
|
if (!map) {
|
|
107
|
-
map = getFileComments(location.file
|
|
106
|
+
map = getFileComments(location.file);
|
|
108
107
|
// cache file info
|
|
109
108
|
cacheMap.set(location.file, map);
|
|
110
109
|
}
|
package/lib/visitor.js
CHANGED
|
@@ -104,21 +104,20 @@ class Visitor {
|
|
|
104
104
|
// data.type is step, metadata is TestStep, https://playwright.dev/docs/api/class-teststep
|
|
105
105
|
async customVisitorsHandler(data, metadata) {
|
|
106
106
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
};
|
|
107
|
+
if (this.options.customFieldsInComments) {
|
|
108
|
+
const customData = commentsPlugin(metadata);
|
|
109
|
+
Object.assign(data, customData);
|
|
110
|
+
}
|
|
112
111
|
|
|
113
112
|
// for all data
|
|
114
113
|
if (this.customCommonVisitor) {
|
|
115
|
-
await this.customCommonVisitor.call(this, data, metadata
|
|
114
|
+
await this.customCommonVisitor.call(this, data, metadata);
|
|
116
115
|
}
|
|
117
116
|
|
|
118
117
|
// for single column data (high priority)
|
|
119
118
|
if (this.customVisitors) {
|
|
120
119
|
for (const item of this.customVisitors) {
|
|
121
|
-
const res = await item.visitor.call(this, data, metadata
|
|
120
|
+
const res = await item.visitor.call(this, data, metadata);
|
|
122
121
|
if (typeof res !== 'undefined') {
|
|
123
122
|
data[item.id] = res;
|
|
124
123
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "monocart-reporter",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "A playwright test reporter. Shows suites/cases/steps with tree style, markdown annotations, custom columns/formatters/data collection visitors, console logs, style tags, send email.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -44,18 +44,18 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"console-grid": "~2.0.1",
|
|
46
46
|
"eight-colors": "~1.0.3",
|
|
47
|
-
"
|
|
48
|
-
"koa": "~2.14.2",
|
|
47
|
+
"koa": "~2.15.0",
|
|
49
48
|
"koa-static-resolver": "~1.0.4",
|
|
50
49
|
"lz-utils": "~2.0.1",
|
|
51
|
-
"monocart-coverage-reports": "~2.0.
|
|
52
|
-
"
|
|
53
|
-
"
|
|
50
|
+
"monocart-coverage-reports": "~2.0.9",
|
|
51
|
+
"monocart-formatter": "^2.2.1",
|
|
52
|
+
"nodemailer": "~6.9.8",
|
|
53
|
+
"open": "~10.0.2",
|
|
54
54
|
"turbogrid": "^3.0.12"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@playwright/test": "^1.40.1",
|
|
58
|
-
"axios": "^1.6.
|
|
58
|
+
"axios": "^1.6.5",
|
|
59
59
|
"dotenv": "^16.3.1",
|
|
60
60
|
"eslint": "^8.56.0",
|
|
61
61
|
"eslint-config-plus": "^1.0.6",
|