@testomatio/reporter 2.1.0 → 2.1.2-beta.1-alias
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 +4 -3
- package/lib/bin/startTest.js +38 -91
- package/lib/pipe/testomatio.js +1 -2
- package/lib/reporter-functions.d.ts +12 -6
- package/lib/reporter-functions.js +11 -5
- package/lib/reporter.d.ts +8 -8
- package/lib/reporter.js +6 -6
- package/package.json +1 -1
- package/src/adapter/codecept.js +4 -3
- package/src/bin/startTest.js +43 -114
- package/src/pipe/testomatio.js +1 -2
- package/src/reporter-functions.js +11 -5
- package/src/reporter.js +6 -6
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;
|
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/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);
|
|
@@ -9,6 +9,8 @@ export default _default;
|
|
|
9
9
|
/**
|
|
10
10
|
* Stores path to file as artifact and uploads it to the S3 storage
|
|
11
11
|
* @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
|
|
12
|
+
* @param {any} [context=null] - optional context parameter
|
|
13
|
+
* @returns {void}
|
|
12
14
|
*/
|
|
13
15
|
declare function saveArtifact(data: string | {
|
|
14
16
|
path: string;
|
|
@@ -17,18 +19,21 @@ declare function saveArtifact(data: string | {
|
|
|
17
19
|
}, context?: any): void;
|
|
18
20
|
/**
|
|
19
21
|
* Attach log message(s) to the test report
|
|
20
|
-
* @param
|
|
22
|
+
* @param {...any} args - log messages to attach
|
|
23
|
+
* @returns {void}
|
|
21
24
|
*/
|
|
22
25
|
declare function logMessage(...args: any[]): void;
|
|
23
26
|
/**
|
|
24
27
|
* Similar to "log" function but marks message in report as a step
|
|
25
|
-
* @param {string} message
|
|
28
|
+
* @param {string} message - step message
|
|
29
|
+
* @returns {void}
|
|
26
30
|
*/
|
|
27
31
|
declare function addStep(message: string): void;
|
|
28
32
|
/**
|
|
29
33
|
* 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
|
|
34
|
+
* @param {{[key: string]: string} | string} keyValue - object { key: value } (multiple props allowed) or key (string)
|
|
35
|
+
* @param {string|null} [value=null] - optional value when keyValue is a string
|
|
36
|
+
* @returns {void}
|
|
32
37
|
*/
|
|
33
38
|
declare function setKeyValue(keyValue: {
|
|
34
39
|
[key: string]: string;
|
|
@@ -36,6 +41,7 @@ declare function setKeyValue(keyValue: {
|
|
|
36
41
|
/**
|
|
37
42
|
* Add a single label to the test report
|
|
38
43
|
* @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')
|
|
44
|
+
* @param {string|null} [value=null] - optional label value (e.g. 'high', 'login')
|
|
45
|
+
* @returns {void}
|
|
40
46
|
*/
|
|
41
|
-
declare function setLabel(key: string, value?: string): void;
|
|
47
|
+
declare function setLabel(key: string, value?: string | null): 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)
|
|
@@ -47,7 +52,8 @@ function setKeyValue(keyValue, value = null) {
|
|
|
47
52
|
/**
|
|
48
53
|
* Add a single label 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|null} [value=null] - optional label value (e.g. 'high', 'login')
|
|
56
|
+
* @returns {void}
|
|
51
57
|
*/
|
|
52
58
|
function setLabel(key, value = null) {
|
|
53
59
|
if (!key || typeof key !== 'string') {
|
package/lib/reporter.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
export type artifact = typeof import("./reporter-functions.js");
|
|
2
1
|
export const artifact: (data: string | {
|
|
3
2
|
path: string;
|
|
4
3
|
type: string;
|
|
5
4
|
name: string;
|
|
6
5
|
}, context?: any) => void;
|
|
7
|
-
export type log = typeof import("./reporter-functions.js");
|
|
8
6
|
export const log: (...args: any[]) => void;
|
|
9
|
-
export type logger = typeof import("./services/index.js");
|
|
10
7
|
export const logger: {
|
|
11
8
|
"__#13@#originalUserLogger": {
|
|
12
9
|
assert(condition?: boolean, ...data: any[]): void;
|
|
@@ -75,14 +72,11 @@ export const logger: {
|
|
|
75
72
|
}): void;
|
|
76
73
|
prettyObjects: boolean;
|
|
77
74
|
};
|
|
78
|
-
export type meta = typeof import("./reporter-functions.js");
|
|
79
75
|
export const meta: (keyValue: {
|
|
80
76
|
[key: string]: string;
|
|
81
77
|
} | string, value?: string | null) => void;
|
|
82
|
-
export type step = typeof import("./reporter-functions.js");
|
|
83
78
|
export const step: (message: string) => void;
|
|
84
|
-
export
|
|
85
|
-
export const label: (key: string, value?: string) => void;
|
|
79
|
+
export const label: (key: string, value?: string | null) => void;
|
|
86
80
|
declare namespace _default {
|
|
87
81
|
let testomatioLogger: {
|
|
88
82
|
"__#13@#originalUserLogger": {
|
|
@@ -230,6 +224,12 @@ declare namespace _default {
|
|
|
230
224
|
[key: string]: string;
|
|
231
225
|
} | string, value?: string | null) => void;
|
|
232
226
|
let step: (message: string) => void;
|
|
233
|
-
let label: (key: string, value?: string) => void;
|
|
227
|
+
let label: (key: string, value?: string | null) => void;
|
|
234
228
|
}
|
|
235
229
|
export default _default;
|
|
230
|
+
export type ArtifactFunction = typeof import("./reporter-functions.js").default.artifact;
|
|
231
|
+
export type LogFunction = typeof import("./reporter-functions.js").default.log;
|
|
232
|
+
export type LoggerService = typeof import("./services/index.js").services.logger;
|
|
233
|
+
export type MetaFunction = typeof import("./reporter-functions.js").default.keyValue;
|
|
234
|
+
export type StepFunction = typeof import("./reporter-functions.js").default.step;
|
|
235
|
+
export type LabelFunction = typeof import("./reporter-functions.js").default.label;
|
package/lib/reporter.js
CHANGED
|
@@ -15,12 +15,12 @@ exports.meta = reporter_functions_js_1.default.keyValue;
|
|
|
15
15
|
exports.step = reporter_functions_js_1.default.step;
|
|
16
16
|
exports.label = reporter_functions_js_1.default.label;
|
|
17
17
|
/**
|
|
18
|
-
* @typedef {import('./reporter-functions.js')}
|
|
19
|
-
* @typedef {import('./reporter-functions.js')}
|
|
20
|
-
* @typedef {import('./services/index.js')}
|
|
21
|
-
* @typedef {import('./reporter-functions.js')}
|
|
22
|
-
* @typedef {import('./reporter-functions.js')}
|
|
23
|
-
* @typedef {import('./reporter-functions.js')}
|
|
18
|
+
* @typedef {typeof import('./reporter-functions.js').default.artifact} ArtifactFunction
|
|
19
|
+
* @typedef {typeof import('./reporter-functions.js').default.log} LogFunction
|
|
20
|
+
* @typedef {typeof import('./services/index.js').services.logger} LoggerService
|
|
21
|
+
* @typedef {typeof import('./reporter-functions.js').default.keyValue} MetaFunction
|
|
22
|
+
* @typedef {typeof import('./reporter-functions.js').default.step} StepFunction
|
|
23
|
+
* @typedef {typeof import('./reporter-functions.js').default.label} LabelFunction
|
|
24
24
|
*/
|
|
25
25
|
module.exports = {
|
|
26
26
|
/**
|
package/package.json
CHANGED
package/src/adapter/codecept.js
CHANGED
|
@@ -56,19 +56,20 @@ function CodeceptReporter(config) {
|
|
|
56
56
|
|
|
57
57
|
output.debug = function(msg) {
|
|
58
58
|
originalOutput.debug(msg);
|
|
59
|
-
dataStorage.putData('log', repeat(this
|
|
59
|
+
dataStorage.putData('log', repeat(this?.stepShift || 0) + pc.cyan(msg.toString()));
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
output.say = function(message, color = 'cyan') {
|
|
63
63
|
originalOutput.say(message, color);
|
|
64
|
-
const sayMsg = repeat(this
|
|
64
|
+
const sayMsg = repeat(this?.stepShift || 0) + ` ${pc.bold(pc[color](message))}`;
|
|
65
65
|
dataStorage.putData('log', sayMsg);
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
output.log = function(msg) {
|
|
69
69
|
originalOutput.log(msg);
|
|
70
|
-
dataStorage.putData('log', repeat(this
|
|
70
|
+
dataStorage.putData('log', repeat(this?.stepShift || 0) + pc.gray(msg));
|
|
71
71
|
};
|
|
72
|
+
output.stepShift = 0;
|
|
72
73
|
|
|
73
74
|
recorder.startUnlessRunning();
|
|
74
75
|
|
package/src/bin/startTest.js
CHANGED
|
@@ -1,124 +1,53 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { spawn } from '
|
|
3
|
-
import {
|
|
4
|
-
import pc from 'picocolors';
|
|
5
|
-
import TestomatClient from '../client.js';
|
|
6
|
-
import { APP_PREFIX, STATUS } from '../constants.js';
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { join, dirname } from 'node:path';
|
|
7
4
|
import { getPackageVersion } from '../utils/utils.js';
|
|
8
|
-
import
|
|
9
|
-
|
|
5
|
+
import pc from 'picocolors';
|
|
6
|
+
|
|
7
|
+
// Define __dirname - this will be replaced by build script with actual __dirname for CommonJS
|
|
8
|
+
const __dirname = typeof globalThis.__dirname !== 'undefined' ? globalThis.__dirname : '.';
|
|
9
|
+
const cliPath = join(__dirname, 'cli.js');
|
|
10
10
|
|
|
11
11
|
const version = getPackageVersion();
|
|
12
12
|
console.log(pc.cyan(pc.bold(` 🤩 Testomat.io Reporter v${version}`)));
|
|
13
|
-
const program = new Command();
|
|
14
|
-
|
|
15
|
-
program
|
|
16
|
-
.option('-c, --command <cmd>', 'Test runner command')
|
|
17
|
-
.option('--launch', 'Start a new run and return its ID')
|
|
18
|
-
.option('--finish', 'Finish Run by its ID')
|
|
19
|
-
.option('--env-file <envfile>', 'Load environment variables from env file')
|
|
20
|
-
.option('--filter <filter>', 'Additional execution filter')
|
|
21
|
-
.action(async opts => {
|
|
22
|
-
const { launch, finish, filter } = opts;
|
|
23
|
-
let { command } = opts;
|
|
24
|
-
|
|
25
|
-
if (opts.envFile) dotenv.config({ path: opts.envFile });
|
|
26
|
-
|
|
27
|
-
const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config.TESTOMATIO;
|
|
28
|
-
const title = process.env.TESTOMATIO_TITLE;
|
|
29
|
-
|
|
30
|
-
if (launch) {
|
|
31
|
-
console.log('Starting a new Run on Testomat.io...');
|
|
32
|
-
const client = new TestomatClient({ apiKey });
|
|
33
|
-
|
|
34
|
-
client.createRun().then(() => {
|
|
35
|
-
console.log(process.env.runId);
|
|
36
|
-
process.exit(0);
|
|
37
|
-
});
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (finish) {
|
|
42
|
-
// TODO: add error in case of TESTOMATIO environment variable is not set
|
|
43
|
-
// because command is fine in console, but actually (on testomat.io) run is not finished
|
|
44
|
-
if (!process.env.TESTOMATIO_RUN) {
|
|
45
|
-
console.log('TESTOMATIO_RUN environment variable must be set.');
|
|
46
|
-
return process.exit(1);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
console.log('Finishing Run on Testomat.io...');
|
|
50
|
-
|
|
51
|
-
const client = new TestomatClient({ apiKey });
|
|
52
13
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
14
|
+
// Parse command line arguments to map start-test-run options to @testomatio/reporter run format
|
|
15
|
+
const args = process.argv.slice(2);
|
|
16
|
+
const newArgs = ['run'];
|
|
17
|
+
|
|
18
|
+
let i = 0;
|
|
19
|
+
while (i < args.length) {
|
|
20
|
+
const arg = args[i];
|
|
21
|
+
|
|
22
|
+
if (arg === '-c' || arg === '--command') {
|
|
23
|
+
// Map -c/--command to positional argument for run command
|
|
24
|
+
i++;
|
|
25
|
+
if (i < args.length) {
|
|
26
|
+
newArgs.push(args[i]);
|
|
59
27
|
}
|
|
28
|
+
} else if (arg.startsWith('--command=')) {
|
|
29
|
+
// Handle --command=value format
|
|
30
|
+
const command = arg.split('=', 2)[1];
|
|
31
|
+
newArgs.push(command);
|
|
32
|
+
} else if (arg === '--launch') {
|
|
33
|
+
// Map --launch to start command
|
|
34
|
+
newArgs[0] = 'start';
|
|
35
|
+
} else if (arg === '--finish') {
|
|
36
|
+
// Map --finish to finish command
|
|
37
|
+
newArgs[0] = 'finish';
|
|
38
|
+
} else {
|
|
39
|
+
// Pass through other arguments
|
|
40
|
+
newArgs.push(arg);
|
|
41
|
+
}
|
|
42
|
+
i++;
|
|
43
|
+
}
|
|
60
44
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (!command.split) {
|
|
64
|
-
process.exitCode = 255;
|
|
65
|
-
console.log(APP_PREFIX, `No command provided. Use -c option to launch a test runner.`);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const client = new TestomatClient({ apiKey, title, parallel: true });
|
|
70
|
-
|
|
71
|
-
if (filter) {
|
|
72
|
-
const [pipe, ...optsArray] = filter.split(':');
|
|
73
|
-
const pipeOptions = optsArray.join(':');
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
const tests = await client.prepareRun({ pipe, pipeOptions });
|
|
77
|
-
|
|
78
|
-
if (!tests || tests.length === 0) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const grep = ` --grep (${tests.join('|')})`;
|
|
83
|
-
command += grep;
|
|
84
|
-
} catch (err) {
|
|
85
|
-
console.log(APP_PREFIX, err);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const testCmds = command.split(' ');
|
|
90
|
-
console.log(APP_PREFIX, `🚀 Running`, pc.green(command));
|
|
91
|
-
|
|
92
|
-
if (!apiKey) {
|
|
93
|
-
const cmd = spawn(testCmds[0], testCmds.slice(1), { stdio: 'inherit' });
|
|
94
|
-
|
|
95
|
-
cmd.on('close', code => {
|
|
96
|
-
console.log(APP_PREFIX, '⚠️ ', `Runner exited with ${pc.bold(code)}, report is ignored`);
|
|
97
|
-
|
|
98
|
-
if (code > exitCode) exitCode = code;
|
|
99
|
-
process.exitCode = exitCode;
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
client.createRun().then(() => {
|
|
106
|
-
const cmd = spawn(testCmds[0], testCmds.slice(1), { stdio: 'inherit' });
|
|
107
|
-
|
|
108
|
-
cmd.on('close', code => {
|
|
109
|
-
const emoji = code === 0 ? '🟢' : '🔴';
|
|
110
|
-
console.log(APP_PREFIX, emoji, `Runner exited with ${pc.bold(code)}`);
|
|
111
|
-
const status = code === 0 ? 'passed' : 'failed';
|
|
112
|
-
client.updateRunStatus(status, true);
|
|
113
|
-
|
|
114
|
-
if (code > exitCode) exitCode = code;
|
|
115
|
-
process.exitCode = exitCode;
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
});
|
|
45
|
+
// Execute the main CLI with mapped arguments
|
|
119
46
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
47
|
+
const child = spawn(process.execPath, [cliPath, ...newArgs], {
|
|
48
|
+
stdio: 'inherit'
|
|
49
|
+
});
|
|
123
50
|
|
|
124
|
-
|
|
51
|
+
child.on('exit', (code) => {
|
|
52
|
+
process.exit(code);
|
|
53
|
+
});
|
package/src/pipe/testomatio.js
CHANGED
|
@@ -119,8 +119,7 @@ class TestomatioPipe {
|
|
|
119
119
|
const resp = await this.client.request({
|
|
120
120
|
method: 'GET',
|
|
121
121
|
url: '/api/test_grep',
|
|
122
|
-
|
|
123
|
-
responseType: q.responseType
|
|
122
|
+
...q,
|
|
124
123
|
});
|
|
125
124
|
|
|
126
125
|
if (Array.isArray(resp.data?.tests) && resp.data?.tests?.length > 0) {
|
|
@@ -3,6 +3,8 @@ import { services } from './services/index.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Stores path to file as artifact and uploads it to the S3 storage
|
|
5
5
|
* @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
|
|
6
|
+
* @param {any} [context=null] - optional context parameter
|
|
7
|
+
* @returns {void}
|
|
6
8
|
*/
|
|
7
9
|
function saveArtifact(data, context = null) {
|
|
8
10
|
if (process.env.IS_PLAYWRIGHT)
|
|
@@ -14,7 +16,8 @@ function saveArtifact(data, context = null) {
|
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Attach log message(s) to the test report
|
|
17
|
-
* @param
|
|
19
|
+
* @param {...any} args - log messages to attach
|
|
20
|
+
* @returns {void}
|
|
18
21
|
*/
|
|
19
22
|
function logMessage(...args) {
|
|
20
23
|
if (process.env.IS_PLAYWRIGHT) throw new Error('This function is not available in Playwright framework');
|
|
@@ -23,7 +26,8 @@ function logMessage(...args) {
|
|
|
23
26
|
|
|
24
27
|
/**
|
|
25
28
|
* Similar to "log" function but marks message in report as a step
|
|
26
|
-
* @param {string} message
|
|
29
|
+
* @param {string} message - step message
|
|
30
|
+
* @returns {void}
|
|
27
31
|
*/
|
|
28
32
|
function addStep(message) {
|
|
29
33
|
if (process.env.IS_PLAYWRIGHT)
|
|
@@ -34,8 +38,9 @@ function addStep(message) {
|
|
|
34
38
|
|
|
35
39
|
/**
|
|
36
40
|
* Add key-value pair(s) to the test report
|
|
37
|
-
* @param {{[key: string]: string} | string} keyValue object { key: value } (multiple props allowed) or key (string)
|
|
38
|
-
* @param {string
|
|
41
|
+
* @param {{[key: string]: string} | string} keyValue - object { key: value } (multiple props allowed) or key (string)
|
|
42
|
+
* @param {string|null} [value=null] - optional value when keyValue is a string
|
|
43
|
+
* @returns {void}
|
|
39
44
|
*/
|
|
40
45
|
function setKeyValue(keyValue, value = null) {
|
|
41
46
|
if (process.env.IS_PLAYWRIGHT)
|
|
@@ -50,7 +55,8 @@ function setKeyValue(keyValue, value = null) {
|
|
|
50
55
|
/**
|
|
51
56
|
* Add a single label to the test report
|
|
52
57
|
* @param {string} key - label key (e.g. 'severity', 'feature', or just 'smoke' for labels without values)
|
|
53
|
-
* @param {string} [value] - optional label value (e.g. 'high', 'login')
|
|
58
|
+
* @param {string|null} [value=null] - optional label value (e.g. 'high', 'login')
|
|
59
|
+
* @returns {void}
|
|
54
60
|
*/
|
|
55
61
|
function setLabel(key, value = null) {
|
|
56
62
|
if (!key || typeof key !== 'string') {
|
package/src/reporter.js
CHANGED
|
@@ -11,12 +11,12 @@ export const step = reporterFunctions.step;
|
|
|
11
11
|
export const label = reporterFunctions.label;
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
|
-
* @typedef {import('./reporter-functions.js')}
|
|
15
|
-
* @typedef {import('./reporter-functions.js')}
|
|
16
|
-
* @typedef {import('./services/index.js')}
|
|
17
|
-
* @typedef {import('./reporter-functions.js')}
|
|
18
|
-
* @typedef {import('./reporter-functions.js')}
|
|
19
|
-
* @typedef {import('./reporter-functions.js')}
|
|
14
|
+
* @typedef {typeof import('./reporter-functions.js').default.artifact} ArtifactFunction
|
|
15
|
+
* @typedef {typeof import('./reporter-functions.js').default.log} LogFunction
|
|
16
|
+
* @typedef {typeof import('./services/index.js').services.logger} LoggerService
|
|
17
|
+
* @typedef {typeof import('./reporter-functions.js').default.keyValue} MetaFunction
|
|
18
|
+
* @typedef {typeof import('./reporter-functions.js').default.step} StepFunction
|
|
19
|
+
* @typedef {typeof import('./reporter-functions.js').default.label} LabelFunction
|
|
20
20
|
*/
|
|
21
21
|
export default {
|
|
22
22
|
/**
|