@testomatio/reporter 2.6.0 → 2.6.1
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 +7 -7
- package/lib/adapter/playwright.d.ts +2 -12
- package/lib/adapter/playwright.js +15 -72
- package/lib/adapter/utils/playwright.d.ts +25 -0
- package/lib/adapter/utils/playwright.js +123 -0
- package/lib/adapter/vitest.js +2 -1
- package/lib/bin/cli.js +1 -1
- package/lib/data-storage.js +1 -0
- package/lib/pipe/html.d.ts +2 -3
- package/lib/pipe/html.js +745 -37
- package/lib/pipe/testomatio.js +12 -1
- package/lib/reporter-functions.d.ts +36 -11
- package/lib/reporter-functions.js +67 -25
- package/lib/reporter.d.ts +12 -8
- package/lib/template/testomatio-old.hbs +1421 -0
- package/lib/template/testomatio.hbs +3200 -1157
- package/lib/utils/log-formatter.js +8 -4
- package/package.json +2 -2
- package/src/adapter/playwright.js +15 -79
- package/src/adapter/utils/playwright.js +121 -0
- package/src/adapter/vitest.js +2 -1
- package/src/bin/cli.js +1 -1
- package/src/data-storage.js +1 -0
- package/src/pipe/html.js +844 -38
- package/src/pipe/testomatio.js +12 -1
- package/src/reporter-functions.js +68 -28
- package/src/template/testomatio-old.hbs +1421 -0
- package/src/template/testomatio.hbs +3200 -1157
- package/src/utils/log-formatter.js +9 -4
- package/types/types.d.ts +29 -5
- package/lib/services/labels.d.ts +0 -0
- package/lib/services/labels.js +0 -0
- package/src/services/labels.js +0 -1
package/src/pipe/testomatio.js
CHANGED
|
@@ -262,6 +262,15 @@ class TestomatioPipe {
|
|
|
262
262
|
responseType: 'json',
|
|
263
263
|
});
|
|
264
264
|
if (resp.data.artifacts) setS3Credentials(resp.data.artifacts);
|
|
265
|
+
if (resp.data.url) {
|
|
266
|
+
const respUrl = new URL(resp.data.url);
|
|
267
|
+
this.runUrl = `${this.url}${respUrl.pathname}`;
|
|
268
|
+
this.runPublicUrl = resp.data.public_url;
|
|
269
|
+
this.store.runUrl = this.runUrl;
|
|
270
|
+
this.store.runPublicUrl = this.runPublicUrl;
|
|
271
|
+
console.log(APP_PREFIX, '📊 Using existing run. Report ID:', this.runId);
|
|
272
|
+
console.log(APP_PREFIX, '📊 Report URL:', pc.magenta(this.runUrl));
|
|
273
|
+
}
|
|
265
274
|
return;
|
|
266
275
|
}
|
|
267
276
|
|
|
@@ -574,7 +583,9 @@ function printCreateIssue() {
|
|
|
574
583
|
* @returns {string}
|
|
575
584
|
*/
|
|
576
585
|
function hideTestomatioToken(data) {
|
|
577
|
-
return
|
|
586
|
+
return (typeof data === 'string' ? data : '')
|
|
587
|
+
.replace(/"api_key"\s*:\s*"[^"]+"/g, '"api_key": "<hidden>"')
|
|
588
|
+
.replace(/"(tstmt_[^"]+)"/g, '"tstmt_***"');
|
|
578
589
|
}
|
|
579
590
|
|
|
580
591
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { playwrightLogsMarkers } from './adapter/utils/playwright.js';
|
|
1
2
|
import { isPlaywright } from './helpers.js';
|
|
2
3
|
import { services } from './services/index.js';
|
|
4
|
+
import pc from 'picocolors';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Stores path to file as artifact and uploads it to the S3 storage
|
|
@@ -8,7 +10,10 @@ import { services } from './services/index.js';
|
|
|
8
10
|
* @returns {void}
|
|
9
11
|
*/
|
|
10
12
|
function saveArtifact(data, context = null) {
|
|
11
|
-
|
|
13
|
+
if (isPlaywright)
|
|
14
|
+
console.warn(`[TESTOMATIO] 'artifact' function is not supported for Playwright
|
|
15
|
+
Playwright supports artifacts out of the box.`);
|
|
16
|
+
|
|
12
17
|
if (!data) return;
|
|
13
18
|
services.artifacts.put(data, context);
|
|
14
19
|
}
|
|
@@ -41,69 +46,104 @@ function addStep(message, logs) {
|
|
|
41
46
|
|
|
42
47
|
/**
|
|
43
48
|
* Add key-value pair(s) to the test report
|
|
44
|
-
* @param {{[key: string]: string} | string} keyValue - object { key: value } (multiple props allowed)
|
|
45
|
-
* @param {string|
|
|
49
|
+
* @param {{[key: string]: string} | string} keyValue - object { key: value } (multiple props allowed) OR key (string)
|
|
50
|
+
* @param {string|undefined} [value=undefined] - optional value when keyValue is a string
|
|
46
51
|
* @returns {void}
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* meta('key', 'value');
|
|
55
|
+
* meta({ key: 'value' });
|
|
56
|
+
* meta({ key1: 'value1', key2: 'value2' });
|
|
47
57
|
*/
|
|
48
|
-
function setKeyValue(keyValue, value =
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
function setKeyValue(keyValue, value = undefined) {
|
|
59
|
+
// in this case keyValue acts as key (value passed as second argument)
|
|
51
60
|
if (typeof keyValue === 'string') {
|
|
52
|
-
|
|
61
|
+
const key = keyValue;
|
|
62
|
+
keyValue = { [key]: value };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (isPlaywright) {
|
|
66
|
+
console.log(`${playwrightLogsMarkers.meta} ${JSON.stringify(keyValue)}`);
|
|
67
|
+
return;
|
|
53
68
|
}
|
|
69
|
+
|
|
70
|
+
// in this case keyValue is expected to be an object
|
|
54
71
|
services.keyValues.put(keyValue);
|
|
55
72
|
}
|
|
56
73
|
|
|
57
74
|
/**
|
|
58
|
-
*
|
|
59
|
-
* @param {string
|
|
60
|
-
*
|
|
75
|
+
* Adds label(s) to the test
|
|
76
|
+
* @param {string | {
|
|
77
|
+
* [key: string]: string}
|
|
78
|
+
* } key - just label OR custom field name OR object with custom field name and value
|
|
79
|
+
* @param {string | null} [value=null] - optional label value (of custom field value)
|
|
80
|
+
* (used when key is a string)
|
|
61
81
|
* @returns {void}
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* label('high');
|
|
85
|
+
* label('priority', 'high');
|
|
86
|
+
* label({priority: 'high'});
|
|
62
87
|
*/
|
|
63
88
|
function setLabel(key, value = null) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
89
|
+
let labelsArr = [];
|
|
90
|
+
|
|
91
|
+
// process label('priority', 'high') and label('high'
|
|
92
|
+
if (typeof key === 'string') {
|
|
93
|
+
labelsArr = [value ? `${key}:${value}` : key];
|
|
94
|
+
// process label({priority: 'high'}), label({priority: 'high', scope: 'smoke'})
|
|
95
|
+
} else if (key !== null && typeof key === 'object') {
|
|
96
|
+
labelsArr = Object.entries(key).map(([key, value]) => `${key}:${value}`);
|
|
67
97
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
98
|
+
|
|
99
|
+
const labels = labelsArr.map(l => ({ label: l }));
|
|
100
|
+
if (isPlaywright) {
|
|
101
|
+
console.log(`${playwrightLogsMarkers.label} ${JSON.stringify(labels)}`);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
services.links.put(labels);
|
|
71
105
|
}
|
|
72
106
|
|
|
73
107
|
/**
|
|
74
108
|
* Add link(s) to the test report
|
|
75
|
-
* @param {...string} testIds - test IDs to link
|
|
109
|
+
* @param {...string | string[]} testIds - test IDs to link
|
|
76
110
|
* @returns {void}
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* linkTest('T11111111', 'T22222222')
|
|
114
|
+
* or
|
|
115
|
+
* linkTest(['T11111111', 'T22222222'])
|
|
77
116
|
*/
|
|
78
117
|
function linkTest(...testIds) {
|
|
118
|
+
const testIdsArr = testIds.flat();
|
|
119
|
+
const links = testIdsArr.map(testId => ({ test: testId }));
|
|
79
120
|
if (isPlaywright) {
|
|
80
|
-
console.log(
|
|
121
|
+
console.log(`${playwrightLogsMarkers.linkTest} ${JSON.stringify(links)}`);
|
|
81
122
|
return;
|
|
82
123
|
}
|
|
83
|
-
const links = testIds.map(testId => ({ test: testId }));
|
|
84
124
|
services.links.put(links);
|
|
85
125
|
}
|
|
86
126
|
|
|
87
127
|
/**
|
|
88
128
|
* Add JIRA issue link(s) to the test report
|
|
89
|
-
* @param {...string} jiraIds - JIRA issue IDs to link
|
|
129
|
+
* @param {...(string | string[])} jiraIds - JIRA issue IDs to link
|
|
90
130
|
* @returns {void}
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* linkJira('TICKET-1', 'TICKET-2')
|
|
134
|
+
* or
|
|
135
|
+
* linkJira(['TICKET-1', 'TICKET-2'])
|
|
91
136
|
*/
|
|
92
137
|
function linkJira(...jiraIds) {
|
|
138
|
+
const jiraIdsArr = jiraIds.flat();
|
|
139
|
+
const links = jiraIdsArr.map(jiraId => ({ jira: jiraId }));
|
|
93
140
|
if (isPlaywright) {
|
|
94
|
-
console.log(
|
|
141
|
+
console.log(`${playwrightLogsMarkers.linkJira} ${JSON.stringify(links)}`);
|
|
95
142
|
return;
|
|
96
143
|
}
|
|
97
|
-
const links = jiraIds.map(jiraId => ({ jira: jiraId }));
|
|
98
144
|
services.links.put(links);
|
|
99
145
|
}
|
|
100
146
|
|
|
101
|
-
function showPlaywrightWarning(functionName, recommendation) {
|
|
102
|
-
if (isPlaywright) {
|
|
103
|
-
console.warn(`[TESTOMATIO] '${functionName}' function is not supported for Playwright. ${recommendation}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
147
|
export default {
|
|
108
148
|
artifact: saveArtifact,
|
|
109
149
|
log: logMessage,
|