@testomatio/reporter 2.1.0-beta.2-codeceptjs → 2.1.0-beta.5-codeceptjs
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/adapter/webdriver.js +9 -3
- package/lib/bin/cli.js +7 -5
- package/lib/bin/reportXml.js +0 -0
- package/lib/bin/startTest.js +0 -0
- package/lib/bin/uploadArtifacts.js +0 -0
- package/lib/client.d.ts +1 -1
- package/lib/client.js +6 -2
- package/lib/pipe/testomatio.js +6 -3
- 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/lib/utils/pipe_utils.js +5 -2
- package/lib/utils/utils.d.ts +6 -1
- package/lib/utils/utils.js +23 -2
- package/package.json +1 -1
- package/src/adapter/codecept.js +4 -3
- package/src/bin/cli.js +0 -0
- package/src/bin/uploadArtifacts.js +0 -0
- package/src/pipe/testomatio.js +1 -1
- package/src/reporter-functions.js +11 -5
- package/src/reporter.js +6 -6
- package/src/utils/pipe_utils.js +6 -2
- package/src/reporter.cjs_decprecated +0 -21
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/adapter/webdriver.js
CHANGED
|
@@ -48,8 +48,9 @@ class WebdriverReporter extends reporter_1.default {
|
|
|
48
48
|
options = Object.assign(options, { stdout: true });
|
|
49
49
|
this._addTestPromises = [];
|
|
50
50
|
this._isSynchronising = false;
|
|
51
|
-
//
|
|
52
|
-
|
|
51
|
+
// run is created by cli, if enabling the row below, it mat lead to multiple runs being created
|
|
52
|
+
// thus, need to check if process.env.runId is set and/or add more checks to avoid creating multiple runs
|
|
53
|
+
// this.client.createRun();
|
|
53
54
|
}
|
|
54
55
|
get isSynchronised() {
|
|
55
56
|
return this._isSynchronising === false;
|
|
@@ -68,7 +69,6 @@ class WebdriverReporter extends reporter_1.default {
|
|
|
68
69
|
}
|
|
69
70
|
onRunnerStart() {
|
|
70
71
|
// clear dir with artifacts/logs
|
|
71
|
-
//
|
|
72
72
|
utils_js_1.fileSystem.clearDir(constants_js_1.TESTOMAT_TMP_STORAGE_DIR);
|
|
73
73
|
}
|
|
74
74
|
onTestStart(test) {
|
|
@@ -153,3 +153,9 @@ function getTestLogs(fullTestTitle) {
|
|
|
153
153
|
return logs;
|
|
154
154
|
}
|
|
155
155
|
module.exports = WebdriverReporter;
|
|
156
|
+
/* INVESTIGATION RESULTS:
|
|
157
|
+
If you run tests in parallel, the WDIO creates a separate process for each parallel instance.
|
|
158
|
+
As a result, there is own WDIOReporter instance for each parallel process.
|
|
159
|
+
This means, its impossible to create or finish run, because can't understand if its was already created
|
|
160
|
+
in other process or not.
|
|
161
|
+
*/
|
package/lib/bin/cli.js
CHANGED
|
@@ -38,6 +38,7 @@ program
|
|
|
38
38
|
.command('start')
|
|
39
39
|
.description('Start a new run and return its ID')
|
|
40
40
|
.action(async () => {
|
|
41
|
+
(0, utils_js_1.cleanLatestRunId)();
|
|
41
42
|
console.log('Starting a new Run on Testomat.io...');
|
|
42
43
|
const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config_js_1.config.TESTOMATIO;
|
|
43
44
|
const client = new client_js_1.default({ apiKey });
|
|
@@ -66,6 +67,7 @@ program
|
|
|
66
67
|
});
|
|
67
68
|
program
|
|
68
69
|
.command('run')
|
|
70
|
+
.alias('test')
|
|
69
71
|
.description('Run tests with the specified command')
|
|
70
72
|
.argument('<command>', 'Test runner command')
|
|
71
73
|
.option('--filter <filter>', 'Additional execution filter')
|
|
@@ -91,24 +93,24 @@ program
|
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
console.log(constants_js_1.APP_PREFIX, `🚀 Running`, picocolors_1.default.green(command));
|
|
94
|
-
const runTests = () => {
|
|
96
|
+
const runTests = async () => {
|
|
95
97
|
const testCmds = command.split(' ');
|
|
96
98
|
const cmd = (0, cross_spawn_1.spawn)(testCmds[0], testCmds.slice(1), { stdio: 'inherit' });
|
|
97
|
-
cmd.on('close', code => {
|
|
99
|
+
cmd.on('close', async (code) => {
|
|
98
100
|
const emoji = code === 0 ? '🟢' : '🔴';
|
|
99
101
|
console.log(constants_js_1.APP_PREFIX, emoji, `Runner exited with ${picocolors_1.default.bold(code)}`);
|
|
100
102
|
if (apiKey) {
|
|
101
103
|
const status = code === 0 ? 'passed' : 'failed';
|
|
102
|
-
client.updateRunStatus(status, true);
|
|
104
|
+
await client.updateRunStatus(status, true);
|
|
103
105
|
}
|
|
104
106
|
process.exit(code);
|
|
105
107
|
});
|
|
106
108
|
};
|
|
107
109
|
if (apiKey) {
|
|
108
|
-
client.createRun().then(runTests);
|
|
110
|
+
await client.createRun().then(runTests);
|
|
109
111
|
}
|
|
110
112
|
else {
|
|
111
|
-
runTests();
|
|
113
|
+
await runTests();
|
|
112
114
|
}
|
|
113
115
|
});
|
|
114
116
|
// program
|
package/lib/bin/reportXml.js
CHANGED
|
File without changes
|
package/lib/bin/startTest.js
CHANGED
|
File without changes
|
|
File without changes
|
package/lib/client.d.ts
CHANGED
package/lib/client.js
CHANGED
|
@@ -68,7 +68,7 @@ class Client {
|
|
|
68
68
|
constructor(params = {}) {
|
|
69
69
|
this.paramsForPipesFactory = params;
|
|
70
70
|
this.pipeStore = {};
|
|
71
|
-
this.runId =
|
|
71
|
+
this.runId = '';
|
|
72
72
|
this.queue = Promise.resolve();
|
|
73
73
|
// @ts-ignore this line will be removed in compiled code, because __dirname is defined in commonjs
|
|
74
74
|
const pathToPackageJSON = path_1.default.join(__dirname, '../package.json');
|
|
@@ -158,6 +158,8 @@ class Client {
|
|
|
158
158
|
* @returns {Promise<PipeResult[]>}
|
|
159
159
|
*/
|
|
160
160
|
async addTestRun(status, testData) {
|
|
161
|
+
if (!this.pipes || !this.pipes.length)
|
|
162
|
+
this.pipes = await (0, index_js_1.pipesFactory)(this.paramsForPipesFactory || {}, this.pipeStore);
|
|
161
163
|
// all pipes disabled, skipping
|
|
162
164
|
if (!this.pipes?.filter(p => p.isEnabled).length)
|
|
163
165
|
return [];
|
|
@@ -292,7 +294,9 @@ class Client {
|
|
|
292
294
|
* @param {boolean} [isParallel] - Whether the current test run was executed in parallel with other tests.
|
|
293
295
|
* @returns {Promise<any>} - A Promise that resolves when finishes the run.
|
|
294
296
|
*/
|
|
295
|
-
updateRunStatus(status, isParallel = false) {
|
|
297
|
+
async updateRunStatus(status, isParallel = false) {
|
|
298
|
+
this.pipes ||= await (0, index_js_1.pipesFactory)(this.paramsForPipesFactory || {}, this.pipeStore);
|
|
299
|
+
this.runId ||= (0, utils_js_1.readLatestRunId)();
|
|
296
300
|
debug('Updating run status...');
|
|
297
301
|
// all pipes disabled, skipping
|
|
298
302
|
if (!this.pipes?.filter(p => p.isEnabled).length)
|
package/lib/pipe/testomatio.js
CHANGED
|
@@ -113,7 +113,7 @@ class TestomatioPipe {
|
|
|
113
113
|
const resp = await this.client.request({
|
|
114
114
|
method: 'GET',
|
|
115
115
|
url: '/api/test_grep',
|
|
116
|
-
|
|
116
|
+
...q,
|
|
117
117
|
});
|
|
118
118
|
if (Array.isArray(resp.data?.tests) && resp.data?.tests?.length > 0) {
|
|
119
119
|
(0, utils_js_1.foundedTestLog)(constants_js_1.APP_PREFIX, resp.data.tests);
|
|
@@ -331,11 +331,14 @@ class TestomatioPipe {
|
|
|
331
331
|
* Adds a test to the batch uploader (or reports a single test if batch uploading is disabled)
|
|
332
332
|
*/
|
|
333
333
|
addTest(data) {
|
|
334
|
-
this.isEnabled = this.apiKey ?? this.isEnabled;
|
|
334
|
+
this.isEnabled = !!(this.apiKey ?? this.isEnabled);
|
|
335
335
|
if (!this.isEnabled)
|
|
336
336
|
return;
|
|
337
|
-
|
|
337
|
+
this.runId = this.runId || process.env.runId || this.store.runId || (0, utils_js_1.readLatestRunId)();
|
|
338
|
+
if (!this.runId) {
|
|
339
|
+
console.warn(constants_js_1.APP_PREFIX, picocolors_1.default.red('Run ID is not set, skipping test reporting'));
|
|
338
340
|
return;
|
|
341
|
+
}
|
|
339
342
|
// add test ID + run ID
|
|
340
343
|
if (data.rid)
|
|
341
344
|
data.rid = `${this.runId}-${data.rid}`;
|
|
@@ -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/lib/utils/pipe_utils.js
CHANGED
|
@@ -74,8 +74,11 @@ function parseFilterParams(opts) {
|
|
|
74
74
|
* Returns undefined if the type is not valid.
|
|
75
75
|
*/
|
|
76
76
|
function updateFilterType(type) {
|
|
77
|
-
|
|
78
|
-
const filterTypes = ['tag-name', 'plan
|
|
77
|
+
let typeLowerCase = type.toLowerCase();
|
|
78
|
+
const filterTypes = ['tag-name', 'plan', 'label', 'jira-ticket'];
|
|
79
|
+
if (typeLowerCase === 'plan-id') {
|
|
80
|
+
typeLowerCase = 'plan';
|
|
81
|
+
}
|
|
79
82
|
const filterApi = [
|
|
80
83
|
'tag',
|
|
81
84
|
'plan',
|
package/lib/utils/utils.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export function getPackageVersion(): any;
|
|
|
2
2
|
export const TEST_ID_REGEX: RegExp;
|
|
3
3
|
export const SUITE_ID_REGEX: RegExp;
|
|
4
4
|
export function ansiRegExp(): RegExp;
|
|
5
|
+
export function cleanLatestRunId(): void;
|
|
5
6
|
export function isSameTest(test: any, t: any): boolean;
|
|
6
7
|
export function fetchSourceCode(contents: any, opts?: {}): string;
|
|
7
8
|
export function fetchSourceCodeFromStackTrace(stack?: string): string;
|
|
@@ -29,7 +30,11 @@ export function isValidUrl(s: any): boolean;
|
|
|
29
30
|
* @returns {String|null} suiteId
|
|
30
31
|
*/
|
|
31
32
|
export function parseSuite(suiteTitle: string): string | null;
|
|
32
|
-
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @returns {String|null} latest run ID
|
|
36
|
+
*/
|
|
37
|
+
export function readLatestRunId(): string | null;
|
|
33
38
|
/**
|
|
34
39
|
* Used to remove color codes
|
|
35
40
|
* @param {*} input
|
package/lib/utils/utils.js
CHANGED
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.validateSuiteId = exports.testRunnerHelper = exports.specificTestInfo = exports.parseSuite = exports.isValidUrl = exports.humanize = exports.getTestomatIdFromTestTitle = exports.getCurrentDateTime = exports.foundedTestLog = exports.fileSystem = exports.fetchFilesFromStackTrace = exports.fetchIdFromOutput = exports.fetchIdFromCode = exports.fetchSourceCodeFromStackTrace = exports.fetchSourceCode = exports.isSameTest = exports.ansiRegExp = exports.SUITE_ID_REGEX = exports.TEST_ID_REGEX = void 0;
|
|
40
40
|
exports.getPackageVersion = getPackageVersion;
|
|
41
|
+
exports.cleanLatestRunId = cleanLatestRunId;
|
|
41
42
|
exports.formatStep = formatStep;
|
|
42
43
|
exports.readLatestRunId = readLatestRunId;
|
|
43
44
|
exports.removeColorCodes = removeColorCodes;
|
|
@@ -391,6 +392,10 @@ function storeRunId(runId) {
|
|
|
391
392
|
const filePath = path_1.default.join(os_1.default.tmpdir(), `testomatio.latest.run`);
|
|
392
393
|
fs_1.default.writeFileSync(filePath, runId);
|
|
393
394
|
}
|
|
395
|
+
/**
|
|
396
|
+
*
|
|
397
|
+
* @returns {String|null} latest run ID
|
|
398
|
+
*/
|
|
394
399
|
function readLatestRunId() {
|
|
395
400
|
try {
|
|
396
401
|
const filePath = path_1.default.join(os_1.default.tmpdir(), `testomatio.latest.run`);
|
|
@@ -398,13 +403,27 @@ function readLatestRunId() {
|
|
|
398
403
|
const diff = +new Date() - +stats.mtime;
|
|
399
404
|
const diffHours = diff / 1000 / 60 / 60;
|
|
400
405
|
if (diffHours > 1)
|
|
401
|
-
return;
|
|
402
|
-
return fs_1.default.readFileSync(filePath)?.toString()?.trim();
|
|
406
|
+
return null;
|
|
407
|
+
return fs_1.default.readFileSync(filePath)?.toString()?.trim() ?? null;
|
|
403
408
|
}
|
|
404
409
|
catch (e) {
|
|
410
|
+
console.warn('Could not read latest run ID from file: ', e);
|
|
405
411
|
return null;
|
|
406
412
|
}
|
|
407
413
|
}
|
|
414
|
+
function cleanLatestRunId() {
|
|
415
|
+
try {
|
|
416
|
+
const filePath = path_1.default.join(os_1.default.tmpdir(), `testomatio.latest.run`);
|
|
417
|
+
const runId = readLatestRunId();
|
|
418
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
419
|
+
fs_1.default.unlinkSync(filePath);
|
|
420
|
+
}
|
|
421
|
+
debug(`Cleaned latest run ID (${runId}) file`, filePath);
|
|
422
|
+
}
|
|
423
|
+
catch (e) {
|
|
424
|
+
console.warn('Could not clean latest run ID file: ', e);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
408
427
|
function formatStep(step, shift = 0) {
|
|
409
428
|
const prefix = ' '.repeat(shift);
|
|
410
429
|
const lines = [];
|
|
@@ -427,6 +446,8 @@ function getPackageVersion() {
|
|
|
427
446
|
|
|
428
447
|
module.exports.getPackageVersion = getPackageVersion;
|
|
429
448
|
|
|
449
|
+
module.exports.cleanLatestRunId = cleanLatestRunId;
|
|
450
|
+
|
|
430
451
|
module.exports.formatStep = formatStep;
|
|
431
452
|
|
|
432
453
|
module.exports.readLatestRunId = readLatestRunId;
|
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/cli.js
CHANGED
|
File without changes
|
|
File without changes
|
package/src/pipe/testomatio.js
CHANGED
|
@@ -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
|
/**
|
package/src/utils/pipe_utils.js
CHANGED
|
@@ -69,9 +69,13 @@ function parseFilterParams(opts) {
|
|
|
69
69
|
* Returns undefined if the type is not valid.
|
|
70
70
|
*/
|
|
71
71
|
function updateFilterType(type) {
|
|
72
|
-
|
|
72
|
+
let typeLowerCase = type.toLowerCase();
|
|
73
73
|
|
|
74
|
-
const filterTypes = ['tag-name', 'plan
|
|
74
|
+
const filterTypes = ['tag-name', 'plan', 'label', 'jira-ticket'];
|
|
75
|
+
|
|
76
|
+
if (typeLowerCase === 'plan-id') {
|
|
77
|
+
typeLowerCase = 'plan';
|
|
78
|
+
}
|
|
75
79
|
|
|
76
80
|
const filterApi = [
|
|
77
81
|
'tag',
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// const _reporter = require('../lib/reporter.js');
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// /**
|
|
5
|
-
// * @typedef {import('../lib/reporter-functions.js').saveArtifact} artifact
|
|
6
|
-
// * @typedef {import('../lib/reporter-functions.js').log} log
|
|
7
|
-
// * @typedef {import('../lib/reporter-functions.js').logger} logger
|
|
8
|
-
// * @typedef {import('../lib/reporter-functions.js')} meta
|
|
9
|
-
// * @typedef {import('../lib/reporter-functions.js')} step
|
|
10
|
-
// *
|
|
11
|
-
// * "Reporter" type which is object containing all types from the above
|
|
12
|
-
// * @typedef {{artifact: artifact, log: log, logger: logger, meta: meta, step: step, }} Reporter
|
|
13
|
-
// */
|
|
14
|
-
|
|
15
|
-
// // const reporter = _reporter;
|
|
16
|
-
|
|
17
|
-
// /**
|
|
18
|
-
// * @type {Reporter}
|
|
19
|
-
// */
|
|
20
|
-
// const reporter = _reporter;
|
|
21
|
-
// module.exports = reporter;
|