@testomatio/reporter 2.1.3-beta.1-multi-links → 2.2.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/lib/adapter/codecept.js +6 -5
- package/lib/adapter/mocha.js +14 -0
- package/lib/adapter/webdriver.js +6 -4
- package/lib/bin/startTest.js +38 -91
- package/lib/client.js +6 -3
- package/lib/data-storage.d.ts +4 -4
- package/lib/data-storage.js +6 -6
- package/lib/pipe/testomatio.js +3 -3
- package/lib/reporter-functions.d.ts +20 -7
- package/lib/reporter-functions.js +27 -35
- package/lib/reporter.d.ts +22 -20
- package/lib/reporter.js +9 -7
- package/lib/services/artifacts.d.ts +1 -1
- package/lib/services/index.d.ts +2 -2
- package/lib/services/index.js +2 -2
- package/lib/services/key-values.d.ts +1 -1
- package/lib/services/labels.d.ts +1 -1
- package/lib/services/labels.js +2 -2
- package/lib/services/logger.d.ts +1 -1
- package/lib/utils/utils.js +3 -1
- package/package.json +1 -1
- package/src/adapter/codecept.js +6 -5
- package/src/adapter/mocha.js +15 -0
- package/src/adapter/webdriver.js +6 -4
- package/src/bin/startTest.js +43 -114
- package/src/client.js +5 -3
- package/src/data-storage.js +6 -6
- package/src/pipe/testomatio.js +3 -3
- package/src/reporter-functions.js +27 -37
- package/src/reporter.js +8 -6
- package/src/services/index.js +2 -2
- package/src/services/labels.js +2 -2
- package/src/services/links.js +69 -0
- package/src/utils/utils.js +5 -3
- package/lib/utils/cli_utils.d.ts +0 -1
- package/lib/utils/cli_utils.js +0 -65552
package/lib/adapter/codecept.js
CHANGED
|
@@ -50,17 +50,18 @@ function CodeceptReporter(config) {
|
|
|
50
50
|
};
|
|
51
51
|
output.debug = function (msg) {
|
|
52
52
|
originalOutput.debug(msg);
|
|
53
|
-
data_storage_js_1.dataStorage.putData('log', repeat(this
|
|
53
|
+
data_storage_js_1.dataStorage.putData('log', repeat(this?.stepShift || 0) + picocolors_1.default.cyan(msg.toString()));
|
|
54
54
|
};
|
|
55
55
|
output.say = function (message, color = 'cyan') {
|
|
56
56
|
originalOutput.say(message, color);
|
|
57
|
-
const sayMsg = repeat(this
|
|
57
|
+
const sayMsg = repeat(this?.stepShift || 0) + ` ${picocolors_1.default.bold(picocolors_1.default[color](message))}`;
|
|
58
58
|
data_storage_js_1.dataStorage.putData('log', sayMsg);
|
|
59
59
|
};
|
|
60
60
|
output.log = function (msg) {
|
|
61
61
|
originalOutput.log(msg);
|
|
62
|
-
data_storage_js_1.dataStorage.putData('log', repeat(this
|
|
62
|
+
data_storage_js_1.dataStorage.putData('log', repeat(this?.stepShift || 0) + picocolors_1.default.gray(msg));
|
|
63
63
|
};
|
|
64
|
+
output.stepShift = 0;
|
|
64
65
|
recorder.startUnlessRunning();
|
|
65
66
|
const hookSteps = new Map();
|
|
66
67
|
let currentHook = null;
|
|
@@ -139,7 +140,7 @@ function CodeceptReporter(config) {
|
|
|
139
140
|
const manuallyAttachedArtifacts = index_js_1.services.artifacts.get(test.fullTitle());
|
|
140
141
|
const keyValues = index_js_1.services.keyValues.get(test.fullTitle());
|
|
141
142
|
const stepHierarchy = buildUnifiedStepHierarchy(test.steps, hookSteps);
|
|
142
|
-
const
|
|
143
|
+
const links = index_js_1.services.links.get(test.fullTitle());
|
|
143
144
|
index_js_1.services.setContext(null);
|
|
144
145
|
client.addTestRun(test.state, {
|
|
145
146
|
...stripExampleFromTitle(title),
|
|
@@ -152,7 +153,7 @@ function CodeceptReporter(config) {
|
|
|
152
153
|
files,
|
|
153
154
|
steps: stepHierarchy, // Array of step objects per API schema
|
|
154
155
|
logs,
|
|
155
|
-
|
|
156
|
+
links,
|
|
156
157
|
manuallyAttachedArtifacts,
|
|
157
158
|
meta: { ...keyValues, ...test.meta },
|
|
158
159
|
});
|
package/lib/adapter/mocha.js
CHANGED
|
@@ -43,6 +43,7 @@ function MochaReporter(runner, opts) {
|
|
|
43
43
|
const logs = getTestLogs(test);
|
|
44
44
|
const artifacts = index_js_1.services.artifacts.get(test.fullTitle());
|
|
45
45
|
const keyValues = index_js_1.services.keyValues.get(test.fullTitle());
|
|
46
|
+
const links = index_js_1.services.links.get(test.fullTitle());
|
|
46
47
|
client.addTestRun(constants_js_1.STATUS.PASSED, {
|
|
47
48
|
test_id: testId,
|
|
48
49
|
suite_title: getSuiteTitle(test),
|
|
@@ -53,12 +54,16 @@ function MochaReporter(runner, opts) {
|
|
|
53
54
|
logs,
|
|
54
55
|
manuallyAttachedArtifacts: artifacts,
|
|
55
56
|
meta: keyValues,
|
|
57
|
+
links,
|
|
56
58
|
});
|
|
57
59
|
});
|
|
58
60
|
runner.on(EVENT_TEST_PENDING, test => {
|
|
59
61
|
skipped += 1;
|
|
60
62
|
console.log('skip: %s', test.fullTitle());
|
|
61
63
|
const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(test.title);
|
|
64
|
+
const artifacts = index_js_1.services.artifacts.get(test.fullTitle());
|
|
65
|
+
const keyValues = index_js_1.services.keyValues.get(test.fullTitle());
|
|
66
|
+
const links = index_js_1.services.links.get(test.fullTitle());
|
|
62
67
|
client.addTestRun(constants_js_1.STATUS.SKIPPED, {
|
|
63
68
|
title: getTestName(test),
|
|
64
69
|
suite_title: getSuiteTitle(test),
|
|
@@ -66,6 +71,9 @@ function MochaReporter(runner, opts) {
|
|
|
66
71
|
file: getFile(test),
|
|
67
72
|
test_id: testId,
|
|
68
73
|
time: test.duration,
|
|
74
|
+
manuallyAttachedArtifacts: artifacts,
|
|
75
|
+
meta: keyValues,
|
|
76
|
+
links,
|
|
69
77
|
});
|
|
70
78
|
});
|
|
71
79
|
runner.on(EVENT_TEST_FAIL, async (test, err) => {
|
|
@@ -73,6 +81,9 @@ function MochaReporter(runner, opts) {
|
|
|
73
81
|
console.log(picocolors_1.default.bold(picocolors_1.default.red('✖')), test.fullTitle(), picocolors_1.default.gray(err.message));
|
|
74
82
|
const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(test.title);
|
|
75
83
|
const logs = getTestLogs(test);
|
|
84
|
+
const artifacts = index_js_1.services.artifacts.get(test.fullTitle());
|
|
85
|
+
const keyValues = index_js_1.services.keyValues.get(test.fullTitle());
|
|
86
|
+
const links = index_js_1.services.links.get(test.fullTitle());
|
|
76
87
|
client.addTestRun(constants_js_1.STATUS.FAILED, {
|
|
77
88
|
error: err,
|
|
78
89
|
suite_title: getSuiteTitle(test),
|
|
@@ -82,6 +93,9 @@ function MochaReporter(runner, opts) {
|
|
|
82
93
|
code: process.env.TESTOMATIO_UPDATE_CODE ? test.body.toString() : '',
|
|
83
94
|
time: test.duration,
|
|
84
95
|
logs,
|
|
96
|
+
manuallyAttachedArtifacts: artifacts,
|
|
97
|
+
meta: keyValues,
|
|
98
|
+
links,
|
|
85
99
|
});
|
|
86
100
|
});
|
|
87
101
|
runner.on(EVENT_RUN_END, () => {
|
package/lib/adapter/webdriver.js
CHANGED
|
@@ -78,11 +78,13 @@ class WebdriverReporter extends reporter_1.default {
|
|
|
78
78
|
test.suite = test.parent;
|
|
79
79
|
const logs = getTestLogs(test.fullTitle);
|
|
80
80
|
// TODO: FIX: artifacts for some reason leads to empty report on Testomat.io
|
|
81
|
-
//
|
|
82
|
-
//
|
|
81
|
+
// ^ not reproduced anymore (Jul 2025)
|
|
82
|
+
// but still be under investigation
|
|
83
|
+
const artifacts = index_js_1.services.artifacts.get(test.fullTitle);
|
|
84
|
+
const keyValues = index_js_1.services.keyValues.get(test.fullTitle);
|
|
83
85
|
test.logs = logs;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
test.artifacts = artifacts;
|
|
87
|
+
test.meta = keyValues;
|
|
86
88
|
this._addTestPromises.push(this.addTest(test));
|
|
87
89
|
}
|
|
88
90
|
// wdio-cucumber does not trigger onTestEnd hook, thus, using this one
|
package/lib/bin/startTest.js
CHANGED
|
@@ -4,103 +4,50 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const picocolors_1 = __importDefault(require("picocolors"));
|
|
10
|
-
const client_js_1 = __importDefault(require("../client.js"));
|
|
11
|
-
const constants_js_1 = require("../constants.js");
|
|
7
|
+
const node_child_process_1 = require("node:child_process");
|
|
8
|
+
const node_path_1 = require("node:path");
|
|
12
9
|
const utils_js_1 = require("../utils/utils.js");
|
|
13
|
-
const
|
|
14
|
-
|
|
10
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
11
|
+
// Define __dirname - this will be replaced by build script with actual __dirname for CommonJS
|
|
12
|
+
const cliPath = (0, node_path_1.join)(__dirname, 'cli.js');
|
|
15
13
|
const version = (0, utils_js_1.getPackageVersion)();
|
|
16
14
|
console.log(picocolors_1.default.cyan(picocolors_1.default.bold(` 🤩 Testomat.io Reporter v${version}`)));
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
dotenv_1.default.config({ path: opts.envFile });
|
|
29
|
-
const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config_js_1.config.TESTOMATIO;
|
|
30
|
-
const title = process.env.TESTOMATIO_TITLE;
|
|
31
|
-
if (launch) {
|
|
32
|
-
console.log('Starting a new Run on Testomat.io...');
|
|
33
|
-
const client = new client_js_1.default({ apiKey });
|
|
34
|
-
client.createRun().then(() => {
|
|
35
|
-
console.log(process.env.runId);
|
|
36
|
-
process.exit(0);
|
|
37
|
-
});
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (finish) {
|
|
41
|
-
// TODO: add error in case of TESTOMATIO environment variable is not set
|
|
42
|
-
// because command is fine in console, but actually (on testomat.io) run is not finished
|
|
43
|
-
if (!process.env.TESTOMATIO_RUN) {
|
|
44
|
-
console.log('TESTOMATIO_RUN environment variable must be set.');
|
|
45
|
-
return process.exit(1);
|
|
15
|
+
// Parse command line arguments to map start-test-run options to @testomatio/reporter run format
|
|
16
|
+
const args = process.argv.slice(2);
|
|
17
|
+
const newArgs = ['run'];
|
|
18
|
+
let i = 0;
|
|
19
|
+
while (i < args.length) {
|
|
20
|
+
const arg = args[i];
|
|
21
|
+
if (arg === '-c' || arg === '--command') {
|
|
22
|
+
// Map -c/--command to positional argument for run command
|
|
23
|
+
i++;
|
|
24
|
+
if (i < args.length) {
|
|
25
|
+
newArgs.push(args[i]);
|
|
46
26
|
}
|
|
47
|
-
console.log('Finishing Run on Testomat.io...');
|
|
48
|
-
const client = new client_js_1.default({ apiKey });
|
|
49
|
-
// @ts-ignore
|
|
50
|
-
client.updateRunStatus(constants_js_1.STATUS.FINISHED).then(() => {
|
|
51
|
-
console.log(picocolors_1.default.yellow(`Run ${process.env.TESTOMATIO_RUN} was finished`));
|
|
52
|
-
process.exit(0);
|
|
53
|
-
});
|
|
54
|
-
return;
|
|
55
27
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return;
|
|
28
|
+
else if (arg.startsWith('--command=')) {
|
|
29
|
+
// Handle --command=value format
|
|
30
|
+
const command = arg.split('=', 2)[1];
|
|
31
|
+
newArgs.push(command);
|
|
61
32
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const pipeOptions = optsArray.join(':');
|
|
66
|
-
try {
|
|
67
|
-
const tests = await client.prepareRun({ pipe, pipeOptions });
|
|
68
|
-
if (!tests || tests.length === 0) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const grep = ` --grep (${tests.join('|')})`;
|
|
72
|
-
command += grep;
|
|
73
|
-
}
|
|
74
|
-
catch (err) {
|
|
75
|
-
console.log(constants_js_1.APP_PREFIX, err);
|
|
76
|
-
}
|
|
33
|
+
else if (arg === '--launch') {
|
|
34
|
+
// Map --launch to start command
|
|
35
|
+
newArgs[0] = 'start';
|
|
77
36
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const cmd = (0, cross_spawn_1.spawn)(testCmds[0], testCmds.slice(1), { stdio: 'inherit' });
|
|
82
|
-
cmd.on('close', code => {
|
|
83
|
-
console.log(constants_js_1.APP_PREFIX, '⚠️ ', `Runner exited with ${picocolors_1.default.bold(code)}, report is ignored`);
|
|
84
|
-
if (code > exitCode)
|
|
85
|
-
exitCode = code;
|
|
86
|
-
process.exitCode = exitCode;
|
|
87
|
-
});
|
|
88
|
-
return;
|
|
37
|
+
else if (arg === '--finish') {
|
|
38
|
+
// Map --finish to finish command
|
|
39
|
+
newArgs[0] = 'finish';
|
|
89
40
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const status = code === 0 ? 'passed' : 'failed';
|
|
96
|
-
client.updateRunStatus(status, true);
|
|
97
|
-
if (code > exitCode)
|
|
98
|
-
exitCode = code;
|
|
99
|
-
process.exitCode = exitCode;
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
if (process.argv.length <= 2) {
|
|
104
|
-
program.outputHelp();
|
|
41
|
+
else {
|
|
42
|
+
// Pass through other arguments
|
|
43
|
+
newArgs.push(arg);
|
|
44
|
+
}
|
|
45
|
+
i++;
|
|
105
46
|
}
|
|
106
|
-
|
|
47
|
+
// Execute the main CLI with mapped arguments
|
|
48
|
+
const child = (0, node_child_process_1.spawn)(process.execPath, [cliPath, ...newArgs], {
|
|
49
|
+
stdio: 'inherit'
|
|
50
|
+
});
|
|
51
|
+
child.on('exit', (code) => {
|
|
52
|
+
process.exit(code);
|
|
53
|
+
});
|
package/lib/client.js
CHANGED
|
@@ -50,6 +50,7 @@ const path_1 = __importStar(require("path"));
|
|
|
50
50
|
const node_url_1 = require("node:url");
|
|
51
51
|
const uploader_js_1 = require("./uploader.js");
|
|
52
52
|
const utils_js_1 = require("./utils/utils.js");
|
|
53
|
+
const links_js_1 = require("./services/links.js");
|
|
53
54
|
const filesize_1 = require("filesize");
|
|
54
55
|
const debug = (0, debug_1.default)('@testomatio/reporter:client');
|
|
55
56
|
// removed __dirname usage, because:
|
|
@@ -181,7 +182,7 @@ class Client {
|
|
|
181
182
|
/**
|
|
182
183
|
* @type {TestData}
|
|
183
184
|
*/
|
|
184
|
-
const { rid, error = null, time = 0, example = null, files = [], filesBuffers = [], steps, code = null, title, file, suite_title, suite_id, test_id, timestamp, manuallyAttachedArtifacts,
|
|
185
|
+
const { rid, error = null, time = 0, example = null, files = [], filesBuffers = [], steps, code = null, title, file, suite_title, suite_id, test_id, timestamp, manuallyAttachedArtifacts, overwrite, } = testData;
|
|
185
186
|
let { message = '', meta = {} } = testData;
|
|
186
187
|
// stringify meta values and limit keys and values length to 255
|
|
187
188
|
meta = Object.entries(meta)
|
|
@@ -220,7 +221,9 @@ class Client {
|
|
|
220
221
|
acc[key] = value;
|
|
221
222
|
return acc;
|
|
222
223
|
}, {});
|
|
223
|
-
//
|
|
224
|
+
// Get links from storage using the test context
|
|
225
|
+
const testContext = suite_title ? `${suite_title} ${title}` : title;
|
|
226
|
+
const links = links_js_1.linkStorage.get(testContext) || [];
|
|
224
227
|
let errorFormatted = '';
|
|
225
228
|
if (error) {
|
|
226
229
|
errorFormatted += this.formatError(error) || '';
|
|
@@ -268,7 +271,7 @@ class Client {
|
|
|
268
271
|
timestamp,
|
|
269
272
|
artifacts,
|
|
270
273
|
meta,
|
|
271
|
-
|
|
274
|
+
links,
|
|
272
275
|
overwrite,
|
|
273
276
|
...(rootSuiteId && { root_suite_id: rootSuiteId }),
|
|
274
277
|
};
|
package/lib/data-storage.d.ts
CHANGED
|
@@ -12,22 +12,22 @@ declare class DataStorage {
|
|
|
12
12
|
/**
|
|
13
13
|
* Puts any data to storage (file or global variable).
|
|
14
14
|
* If file: stores data as text, if global variable – stores as array of data.
|
|
15
|
-
* @param {'log' | 'artifact' | 'keyvalue' | '
|
|
15
|
+
* @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
|
|
16
16
|
* @param {*} data anything you want to store (string, object, array, etc)
|
|
17
17
|
* @param {*} context could be testId or any context (test name, suite name, including their IDs etc)
|
|
18
18
|
* suite name + test name is used by default
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
|
-
putData(dataType: "log" | "artifact" | "keyvalue" | "
|
|
21
|
+
putData(dataType: "log" | "artifact" | "keyvalue" | "links", data: any, context?: any): void;
|
|
22
22
|
/**
|
|
23
23
|
* Returns data, stored for specific test/context (or data which was stored without test id specified).
|
|
24
24
|
* This method will get data from global variable and/or from from file (previosly saved with put method).
|
|
25
25
|
*
|
|
26
|
-
* @param {'log' | 'artifact' | 'keyvalue' | '
|
|
26
|
+
* @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
|
|
27
27
|
* @param {string} context
|
|
28
28
|
* @returns {any []} array of data (any type), null (if no data found for context) or string (if data type is log)
|
|
29
29
|
*/
|
|
30
|
-
getData(dataType: "log" | "artifact" | "keyvalue" | "
|
|
30
|
+
getData(dataType: "log" | "artifact" | "keyvalue" | "links", context: string): any[];
|
|
31
31
|
#private;
|
|
32
32
|
}
|
|
33
33
|
export function stringToMD5Hash(str: any): string;
|
package/lib/data-storage.js
CHANGED
|
@@ -75,7 +75,7 @@ class DataStorage {
|
|
|
75
75
|
/**
|
|
76
76
|
* Puts any data to storage (file or global variable).
|
|
77
77
|
* If file: stores data as text, if global variable – stores as array of data.
|
|
78
|
-
* @param {'log' | 'artifact' | 'keyvalue' | '
|
|
78
|
+
* @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
|
|
79
79
|
* @param {*} data anything you want to store (string, object, array, etc)
|
|
80
80
|
* @param {*} context could be testId or any context (test name, suite name, including their IDs etc)
|
|
81
81
|
* suite name + test name is used by default
|
|
@@ -103,7 +103,7 @@ class DataStorage {
|
|
|
103
103
|
* Returns data, stored for specific test/context (or data which was stored without test id specified).
|
|
104
104
|
* This method will get data from global variable and/or from from file (previosly saved with put method).
|
|
105
105
|
*
|
|
106
|
-
* @param {'log' | 'artifact' | 'keyvalue' | '
|
|
106
|
+
* @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
|
|
107
107
|
* @param {string} context
|
|
108
108
|
* @returns {any []} array of data (any type), null (if no data found for context) or string (if data type is log)
|
|
109
109
|
*/
|
|
@@ -134,7 +134,7 @@ class DataStorage {
|
|
|
134
134
|
return null;
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
|
-
* @param {'log' | 'artifact' | 'keyvalue' | '
|
|
137
|
+
* @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
|
|
138
138
|
* @param {string} context
|
|
139
139
|
* @returns aray of data (any type)
|
|
140
140
|
*/
|
|
@@ -154,7 +154,7 @@ class DataStorage {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
|
-
* @param {'log' | 'artifact' | 'keyvalue' | '
|
|
157
|
+
* @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
|
|
158
158
|
* @param {*} context
|
|
159
159
|
* @returns array of data (any type)
|
|
160
160
|
*/
|
|
@@ -179,7 +179,7 @@ class DataStorage {
|
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
181
181
|
* Puts data to global variable. Unlike the file storage, stores data in array (file storage just append as string).
|
|
182
|
-
* @param {'log' | 'artifact' | 'keyvalue' | '
|
|
182
|
+
* @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
|
|
183
183
|
* @param {*} data
|
|
184
184
|
* @param {*} context
|
|
185
185
|
*/
|
|
@@ -195,7 +195,7 @@ class DataStorage {
|
|
|
195
195
|
}
|
|
196
196
|
/**
|
|
197
197
|
* Puts data to file. Unlike the global variable storage, stores data as string
|
|
198
|
-
* @param {'log' | 'artifact' | 'keyvalue' | '
|
|
198
|
+
* @param {'log' | 'artifact' | 'keyvalue' | 'links'} dataType
|
|
199
199
|
* @param {*} data
|
|
200
200
|
* @param {string} context
|
|
201
201
|
* @returns
|
package/lib/pipe/testomatio.js
CHANGED
|
@@ -113,8 +113,7 @@ class TestomatioPipe {
|
|
|
113
113
|
const resp = await this.client.request({
|
|
114
114
|
method: 'GET',
|
|
115
115
|
url: '/api/test_grep',
|
|
116
|
-
|
|
117
|
-
responseType: q.responseType
|
|
116
|
+
...q,
|
|
118
117
|
});
|
|
119
118
|
if (Array.isArray(resp.data?.tests) && resp.data?.tests?.length > 0) {
|
|
120
119
|
(0, utils_js_1.foundedTestLog)(constants_js_1.APP_PREFIX, resp.data.tests);
|
|
@@ -173,7 +172,8 @@ class TestomatioPipe {
|
|
|
173
172
|
const resp = await this.client.request({
|
|
174
173
|
method: 'PUT',
|
|
175
174
|
url: `/api/reporter/${this.runId}`,
|
|
176
|
-
data: runParams
|
|
175
|
+
data: runParams,
|
|
176
|
+
responseType: 'json'
|
|
177
177
|
});
|
|
178
178
|
if (resp.data.artifacts)
|
|
179
179
|
(0, pipe_utils_js_1.setS3Credentials)(resp.data.artifacts);
|
|
@@ -4,11 +4,14 @@ declare namespace _default {
|
|
|
4
4
|
export { addStep as step };
|
|
5
5
|
export { setKeyValue as keyValue };
|
|
6
6
|
export { setLabel as label };
|
|
7
|
+
export { linkTest };
|
|
7
8
|
}
|
|
8
9
|
export default _default;
|
|
9
10
|
/**
|
|
10
11
|
* Stores path to file as artifact and uploads it to the S3 storage
|
|
11
12
|
* @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
|
|
13
|
+
* @param {any} [context=null] - optional context parameter
|
|
14
|
+
* @returns {void}
|
|
12
15
|
*/
|
|
13
16
|
declare function saveArtifact(data: string | {
|
|
14
17
|
path: string;
|
|
@@ -17,25 +20,35 @@ declare function saveArtifact(data: string | {
|
|
|
17
20
|
}, context?: any): void;
|
|
18
21
|
/**
|
|
19
22
|
* Attach log message(s) to the test report
|
|
20
|
-
* @param
|
|
23
|
+
* @param {...any} args - log messages to attach
|
|
24
|
+
* @returns {void}
|
|
21
25
|
*/
|
|
22
26
|
declare function logMessage(...args: any[]): void;
|
|
23
27
|
/**
|
|
24
28
|
* Similar to "log" function but marks message in report as a step
|
|
25
|
-
* @param {string} message
|
|
29
|
+
* @param {string} message - step message
|
|
30
|
+
* @returns {void}
|
|
26
31
|
*/
|
|
27
32
|
declare function addStep(message: string): void;
|
|
28
33
|
/**
|
|
29
34
|
* Add key-value pair(s) to the test report
|
|
30
|
-
* @param {{[key: string]: string} | string} keyValue object { key: value } (multiple props allowed) or key (string)
|
|
31
|
-
* @param {string
|
|
35
|
+
* @param {{[key: string]: string} | string} keyValue - object { key: value } (multiple props allowed) or key (string)
|
|
36
|
+
* @param {string|null} [value=null] - optional value when keyValue is a string
|
|
37
|
+
* @returns {void}
|
|
32
38
|
*/
|
|
33
39
|
declare function setKeyValue(keyValue: {
|
|
34
40
|
[key: string]: string;
|
|
35
41
|
} | string, value?: string | null): void;
|
|
36
42
|
/**
|
|
37
|
-
* Add
|
|
43
|
+
* Add label(s) to the test report
|
|
38
44
|
* @param {string} key - label key (e.g. 'severity', 'feature', or just 'smoke' for labels without values)
|
|
39
|
-
* @param {string} [value] - optional label value (e.g. 'high', 'login')
|
|
45
|
+
* @param {string|string[]|null} [value=null] - optional label value(s) (e.g. 'high', 'login') or array of values
|
|
46
|
+
* @returns {void}
|
|
40
47
|
*/
|
|
41
|
-
declare function setLabel(key: string, value?: string): void;
|
|
48
|
+
declare function setLabel(key: string, value?: string | string[] | null): void;
|
|
49
|
+
/**
|
|
50
|
+
* Add link(s) to the test report
|
|
51
|
+
* @param {...string} testIds - test IDs to link
|
|
52
|
+
* @returns {void}
|
|
53
|
+
*/
|
|
54
|
+
declare function linkTest(...testIds: string[]): void;
|
|
@@ -4,6 +4,8 @@ const index_js_1 = require("./services/index.js");
|
|
|
4
4
|
/**
|
|
5
5
|
* Stores path to file as artifact and uploads it to the S3 storage
|
|
6
6
|
* @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
|
|
7
|
+
* @param {any} [context=null] - optional context parameter
|
|
8
|
+
* @returns {void}
|
|
7
9
|
*/
|
|
8
10
|
function saveArtifact(data, context = null) {
|
|
9
11
|
if (process.env.IS_PLAYWRIGHT)
|
|
@@ -15,7 +17,8 @@ function saveArtifact(data, context = null) {
|
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* Attach log message(s) to the test report
|
|
18
|
-
* @param
|
|
20
|
+
* @param {...any} args - log messages to attach
|
|
21
|
+
* @returns {void}
|
|
19
22
|
*/
|
|
20
23
|
function logMessage(...args) {
|
|
21
24
|
if (process.env.IS_PLAYWRIGHT)
|
|
@@ -24,7 +27,8 @@ function logMessage(...args) {
|
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
26
29
|
* Similar to "log" function but marks message in report as a step
|
|
27
|
-
* @param {string} message
|
|
30
|
+
* @param {string} message - step message
|
|
31
|
+
* @returns {void}
|
|
28
32
|
*/
|
|
29
33
|
function addStep(message) {
|
|
30
34
|
if (process.env.IS_PLAYWRIGHT)
|
|
@@ -33,8 +37,9 @@ function addStep(message) {
|
|
|
33
37
|
}
|
|
34
38
|
/**
|
|
35
39
|
* Add key-value pair(s) to the test report
|
|
36
|
-
* @param {{[key: string]: string} | string} keyValue object { key: value } (multiple props allowed) or key (string)
|
|
37
|
-
* @param {string
|
|
40
|
+
* @param {{[key: string]: string} | string} keyValue - object { key: value } (multiple props allowed) or key (string)
|
|
41
|
+
* @param {string|null} [value=null] - optional value when keyValue is a string
|
|
42
|
+
* @returns {void}
|
|
38
43
|
*/
|
|
39
44
|
function setKeyValue(keyValue, value = null) {
|
|
40
45
|
if (process.env.IS_PLAYWRIGHT)
|
|
@@ -45,43 +50,29 @@ function setKeyValue(keyValue, value = null) {
|
|
|
45
50
|
index_js_1.services.keyValues.put(keyValue);
|
|
46
51
|
}
|
|
47
52
|
/**
|
|
48
|
-
* Add
|
|
53
|
+
* Add label(s) to the test report
|
|
49
54
|
* @param {string} key - label key (e.g. 'severity', 'feature', or just 'smoke' for labels without values)
|
|
50
|
-
* @param {string} [value] - optional label value (e.g. 'high', 'login')
|
|
55
|
+
* @param {string|string[]|null} [value=null] - optional label value(s) (e.g. 'high', 'login') or array of values
|
|
56
|
+
* @returns {void}
|
|
51
57
|
*/
|
|
52
58
|
function setLabel(key, value = null) {
|
|
53
59
|
if (Array.isArray(value)) {
|
|
54
|
-
value.forEach(
|
|
60
|
+
value.forEach(val => setLabel(key, val));
|
|
55
61
|
return;
|
|
56
62
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
value = String(value);
|
|
71
|
-
}
|
|
72
|
-
// Limit value length to 255 characters
|
|
73
|
-
if (value.length > 255) {
|
|
74
|
-
console.warn('Label value is too long, trimmed to 255 characters:', value);
|
|
75
|
-
value = value.substring(0, 255);
|
|
76
|
-
}
|
|
77
|
-
labelString = `${key}:${value}`;
|
|
78
|
-
}
|
|
79
|
-
// Limit total label length to 255 characters
|
|
80
|
-
if (labelString.length > 255) {
|
|
81
|
-
console.warn('Label is too long, trimmed to 255 characters:', labelString);
|
|
82
|
-
labelString = labelString.substring(0, 255);
|
|
83
|
-
}
|
|
84
|
-
index_js_1.services.labels.put([labelString]);
|
|
63
|
+
const labelObject = value !== null && value !== undefined && value !== ''
|
|
64
|
+
? { label: `${key}:${value}` }
|
|
65
|
+
: { label: key };
|
|
66
|
+
index_js_1.services.links.put([labelObject]);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Add link(s) to the test report
|
|
70
|
+
* @param {...string} testIds - test IDs to link
|
|
71
|
+
* @returns {void}
|
|
72
|
+
*/
|
|
73
|
+
function linkTest(...testIds) {
|
|
74
|
+
const links = testIds.map(testId => ({ test: testId }));
|
|
75
|
+
index_js_1.services.links.put(links);
|
|
85
76
|
}
|
|
86
77
|
module.exports = {
|
|
87
78
|
artifact: saveArtifact,
|
|
@@ -89,4 +80,5 @@ module.exports = {
|
|
|
89
80
|
step: addStep,
|
|
90
81
|
keyValue: setKeyValue,
|
|
91
82
|
label: setLabel,
|
|
83
|
+
linkTest,
|
|
92
84
|
};
|