@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/lib/pipe/testomatio.js
CHANGED
|
@@ -234,6 +234,15 @@ class TestomatioPipe {
|
|
|
234
234
|
});
|
|
235
235
|
if (resp.data.artifacts)
|
|
236
236
|
(0, pipe_utils_js_1.setS3Credentials)(resp.data.artifacts);
|
|
237
|
+
if (resp.data.url) {
|
|
238
|
+
const respUrl = new URL(resp.data.url);
|
|
239
|
+
this.runUrl = `${this.url}${respUrl.pathname}`;
|
|
240
|
+
this.runPublicUrl = resp.data.public_url;
|
|
241
|
+
this.store.runUrl = this.runUrl;
|
|
242
|
+
this.store.runPublicUrl = this.runPublicUrl;
|
|
243
|
+
console.log(constants_js_1.APP_PREFIX, '📊 Using existing run. Report ID:', this.runId);
|
|
244
|
+
console.log(constants_js_1.APP_PREFIX, '📊 Report URL:', picocolors_1.default.magenta(this.runUrl));
|
|
245
|
+
}
|
|
237
246
|
return;
|
|
238
247
|
}
|
|
239
248
|
debug('Creating run...');
|
|
@@ -514,7 +523,9 @@ function printCreateIssue() {
|
|
|
514
523
|
* @returns {string}
|
|
515
524
|
*/
|
|
516
525
|
function hideTestomatioToken(data) {
|
|
517
|
-
return
|
|
526
|
+
return (typeof data === 'string' ? data : '')
|
|
527
|
+
.replace(/"api_key"\s*:\s*"[^"]+"/g, '"api_key": "<hidden>"')
|
|
528
|
+
.replace(/"(tstmt_[^"]+)"/g, '"tstmt_***"');
|
|
518
529
|
}
|
|
519
530
|
/**
|
|
520
531
|
* Stringifies provided data
|
|
@@ -39,29 +39,54 @@ declare function addStep(message: string, logs?: {
|
|
|
39
39
|
}): void;
|
|
40
40
|
/**
|
|
41
41
|
* Add key-value pair(s) to the test report
|
|
42
|
-
* @param {{[key: string]: string} | string} keyValue - object { key: value } (multiple props allowed)
|
|
43
|
-
* @param {string|
|
|
42
|
+
* @param {{[key: string]: string} | string} keyValue - object { key: value } (multiple props allowed) OR key (string)
|
|
43
|
+
* @param {string|undefined} [value=undefined] - optional value when keyValue is a string
|
|
44
44
|
* @returns {void}
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* meta('key', 'value');
|
|
48
|
+
* meta({ key: 'value' });
|
|
49
|
+
* meta({ key1: 'value1', key2: 'value2' });
|
|
45
50
|
*/
|
|
46
51
|
declare function setKeyValue(keyValue: {
|
|
47
52
|
[key: string]: string;
|
|
48
|
-
} | string, value?: string |
|
|
53
|
+
} | string, value?: string | undefined): void;
|
|
49
54
|
/**
|
|
50
|
-
*
|
|
51
|
-
* @param {string
|
|
52
|
-
*
|
|
55
|
+
* Adds label(s) to the test
|
|
56
|
+
* @param {string | {
|
|
57
|
+
* [key: string]: string}
|
|
58
|
+
* } key - just label OR custom field name OR object with custom field name and value
|
|
59
|
+
* @param {string | null} [value=null] - optional label value (of custom field value)
|
|
60
|
+
* (used when key is a string)
|
|
53
61
|
* @returns {void}
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* label('high');
|
|
65
|
+
* label('priority', 'high');
|
|
66
|
+
* label({priority: 'high'});
|
|
54
67
|
*/
|
|
55
|
-
declare function setLabel(key: string
|
|
68
|
+
declare function setLabel(key: string | {
|
|
69
|
+
[key: string]: string;
|
|
70
|
+
}, value?: string | null): void;
|
|
56
71
|
/**
|
|
57
72
|
* Add link(s) to the test report
|
|
58
|
-
* @param {...string} testIds - test IDs to link
|
|
73
|
+
* @param {...string | string[]} testIds - test IDs to link
|
|
59
74
|
* @returns {void}
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* linkTest('T11111111', 'T22222222')
|
|
78
|
+
* or
|
|
79
|
+
* linkTest(['T11111111', 'T22222222'])
|
|
60
80
|
*/
|
|
61
|
-
declare function linkTest(...testIds: string[]): void;
|
|
81
|
+
declare function linkTest(...testIds: (string | string[])[]): void;
|
|
62
82
|
/**
|
|
63
83
|
* Add JIRA issue link(s) to the test report
|
|
64
|
-
* @param {...string} jiraIds - JIRA issue IDs to link
|
|
84
|
+
* @param {...(string | string[])} jiraIds - JIRA issue IDs to link
|
|
65
85
|
* @returns {void}
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* linkJira('TICKET-1', 'TICKET-2')
|
|
89
|
+
* or
|
|
90
|
+
* linkJira(['TICKET-1', 'TICKET-2'])
|
|
66
91
|
*/
|
|
67
|
-
declare function linkJira(...jiraIds: string[]): void;
|
|
92
|
+
declare function linkJira(...jiraIds: (string | string[])[]): void;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const playwright_js_1 = require("./adapter/utils/playwright.js");
|
|
3
7
|
const helpers_js_1 = require("./helpers.js");
|
|
4
8
|
const index_js_1 = require("./services/index.js");
|
|
9
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
5
10
|
/**
|
|
6
11
|
* Stores path to file as artifact and uploads it to the S3 storage
|
|
7
12
|
* @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
|
|
@@ -9,7 +14,9 @@ const index_js_1 = require("./services/index.js");
|
|
|
9
14
|
* @returns {void}
|
|
10
15
|
*/
|
|
11
16
|
function saveArtifact(data, context = null) {
|
|
12
|
-
|
|
17
|
+
if (helpers_js_1.isPlaywright)
|
|
18
|
+
console.warn(`[TESTOMATIO] 'artifact' function is not supported for Playwright
|
|
19
|
+
Playwright supports artifacts out of the box.`);
|
|
13
20
|
if (!data)
|
|
14
21
|
return;
|
|
15
22
|
index_js_1.services.artifacts.put(data, context);
|
|
@@ -42,62 +49,97 @@ function addStep(message, logs) {
|
|
|
42
49
|
}
|
|
43
50
|
/**
|
|
44
51
|
* Add key-value pair(s) to the test report
|
|
45
|
-
* @param {{[key: string]: string} | string} keyValue - object { key: value } (multiple props allowed)
|
|
46
|
-
* @param {string|
|
|
52
|
+
* @param {{[key: string]: string} | string} keyValue - object { key: value } (multiple props allowed) OR key (string)
|
|
53
|
+
* @param {string|undefined} [value=undefined] - optional value when keyValue is a string
|
|
47
54
|
* @returns {void}
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* meta('key', 'value');
|
|
58
|
+
* meta({ key: 'value' });
|
|
59
|
+
* meta({ key1: 'value1', key2: 'value2' });
|
|
48
60
|
*/
|
|
49
|
-
function setKeyValue(keyValue, value =
|
|
50
|
-
|
|
61
|
+
function setKeyValue(keyValue, value = undefined) {
|
|
62
|
+
// in this case keyValue acts as key (value passed as second argument)
|
|
51
63
|
if (typeof keyValue === 'string') {
|
|
52
|
-
|
|
64
|
+
const key = keyValue;
|
|
65
|
+
keyValue = { [key]: value };
|
|
66
|
+
}
|
|
67
|
+
if (helpers_js_1.isPlaywright) {
|
|
68
|
+
console.log(`${playwright_js_1.playwrightLogsMarkers.meta} ${JSON.stringify(keyValue)}`);
|
|
69
|
+
return;
|
|
53
70
|
}
|
|
71
|
+
// in this case keyValue is expected to be an object
|
|
54
72
|
index_js_1.services.keyValues.put(keyValue);
|
|
55
73
|
}
|
|
56
74
|
/**
|
|
57
|
-
*
|
|
58
|
-
* @param {string
|
|
59
|
-
*
|
|
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)
|
|
60
81
|
* @returns {void}
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* label('high');
|
|
85
|
+
* label('priority', 'high');
|
|
86
|
+
* label({priority: 'high'});
|
|
61
87
|
*/
|
|
62
88
|
function setLabel(key, value = null) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
89
|
+
let labelsArr = [];
|
|
90
|
+
// process label('priority', 'high') and label('high'
|
|
91
|
+
if (typeof key === 'string') {
|
|
92
|
+
labelsArr = [value ? `${key}:${value}` : key];
|
|
93
|
+
// process label({priority: 'high'}), label({priority: 'high', scope: 'smoke'})
|
|
94
|
+
}
|
|
95
|
+
else if (key !== null && typeof key === 'object') {
|
|
96
|
+
labelsArr = Object.entries(key).map(([key, value]) => `${key}:${value}`);
|
|
66
97
|
}
|
|
67
|
-
const
|
|
68
|
-
|
|
98
|
+
const labels = labelsArr.map(l => ({ label: l }));
|
|
99
|
+
if (helpers_js_1.isPlaywright) {
|
|
100
|
+
console.log(`${playwright_js_1.playwrightLogsMarkers.label} ${JSON.stringify(labels)}`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
index_js_1.services.links.put(labels);
|
|
69
104
|
}
|
|
70
105
|
/**
|
|
71
106
|
* Add link(s) to the test report
|
|
72
|
-
* @param {...string} testIds - test IDs to link
|
|
107
|
+
* @param {...string | string[]} testIds - test IDs to link
|
|
73
108
|
* @returns {void}
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* linkTest('T11111111', 'T22222222')
|
|
112
|
+
* or
|
|
113
|
+
* linkTest(['T11111111', 'T22222222'])
|
|
74
114
|
*/
|
|
75
115
|
function linkTest(...testIds) {
|
|
116
|
+
const testIdsArr = testIds.flat();
|
|
117
|
+
const links = testIdsArr.map(testId => ({ test: testId }));
|
|
76
118
|
if (helpers_js_1.isPlaywright) {
|
|
77
|
-
console.log(
|
|
119
|
+
console.log(`${playwright_js_1.playwrightLogsMarkers.linkTest} ${JSON.stringify(links)}`);
|
|
78
120
|
return;
|
|
79
121
|
}
|
|
80
|
-
const links = testIds.map(testId => ({ test: testId }));
|
|
81
122
|
index_js_1.services.links.put(links);
|
|
82
123
|
}
|
|
83
124
|
/**
|
|
84
125
|
* Add JIRA issue link(s) to the test report
|
|
85
|
-
* @param {...string} jiraIds - JIRA issue IDs to link
|
|
126
|
+
* @param {...(string | string[])} jiraIds - JIRA issue IDs to link
|
|
86
127
|
* @returns {void}
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* linkJira('TICKET-1', 'TICKET-2')
|
|
131
|
+
* or
|
|
132
|
+
* linkJira(['TICKET-1', 'TICKET-2'])
|
|
87
133
|
*/
|
|
88
134
|
function linkJira(...jiraIds) {
|
|
135
|
+
const jiraIdsArr = jiraIds.flat();
|
|
136
|
+
const links = jiraIdsArr.map(jiraId => ({ jira: jiraId }));
|
|
89
137
|
if (helpers_js_1.isPlaywright) {
|
|
90
|
-
console.log(
|
|
138
|
+
console.log(`${playwright_js_1.playwrightLogsMarkers.linkJira} ${JSON.stringify(links)}`);
|
|
91
139
|
return;
|
|
92
140
|
}
|
|
93
|
-
const links = jiraIds.map(jiraId => ({ jira: jiraId }));
|
|
94
141
|
index_js_1.services.links.put(links);
|
|
95
142
|
}
|
|
96
|
-
function showPlaywrightWarning(functionName, recommendation) {
|
|
97
|
-
if (helpers_js_1.isPlaywright) {
|
|
98
|
-
console.warn(`[TESTOMATIO] '${functionName}' function is not supported for Playwright. ${recommendation}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
143
|
module.exports = {
|
|
102
144
|
artifact: saveArtifact,
|
|
103
145
|
log: logMessage,
|
package/lib/reporter.d.ts
CHANGED
|
@@ -82,13 +82,15 @@ export const logger: {
|
|
|
82
82
|
};
|
|
83
83
|
export const meta: (keyValue: {
|
|
84
84
|
[key: string]: string;
|
|
85
|
-
} | string, value?: string |
|
|
85
|
+
} | string, value?: string | undefined) => void;
|
|
86
86
|
export const step: (message: string, logs?: {
|
|
87
87
|
[key: string]: any;
|
|
88
88
|
}) => void;
|
|
89
|
-
export const label: (key: string
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
export const label: (key: string | {
|
|
90
|
+
[key: string]: string;
|
|
91
|
+
}, value?: string | null) => void;
|
|
92
|
+
export const linkTest: (...testIds: (string | string[])[]) => void;
|
|
93
|
+
export const linkJira: (...jiraIds: (string | string[])[]) => void;
|
|
92
94
|
declare namespace _default {
|
|
93
95
|
export let testomatioLogger: {
|
|
94
96
|
"__#14@#originalUserLogger": {
|
|
@@ -236,13 +238,15 @@ declare namespace _default {
|
|
|
236
238
|
};
|
|
237
239
|
export let meta: (keyValue: {
|
|
238
240
|
[key: string]: string;
|
|
239
|
-
} | string, value?: string |
|
|
241
|
+
} | string, value?: string | undefined) => void;
|
|
240
242
|
export let step: (message: string, logs?: {
|
|
241
243
|
[key: string]: any;
|
|
242
244
|
}) => void;
|
|
243
|
-
export let label: (key: string
|
|
244
|
-
|
|
245
|
-
|
|
245
|
+
export let label: (key: string | {
|
|
246
|
+
[key: string]: string;
|
|
247
|
+
}, value?: string | null) => void;
|
|
248
|
+
export let linkTest: (...testIds: (string | string[])[]) => void;
|
|
249
|
+
export let linkJira: (...jiraIds: (string | string[])[]) => void;
|
|
246
250
|
export { Client as TestomatioClient };
|
|
247
251
|
export { STATUS };
|
|
248
252
|
}
|