@testomatio/reporter 2.1.0 → 2.1.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 +4 -3
- 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/lib/utils/utils.js +3 -1
- package/package.json +1 -1
- package/src/adapter/codecept.js +4 -3
- package/src/pipe/testomatio.js +1 -2
- package/src/reporter-functions.js +11 -5
- package/src/reporter.js +6 -6
- package/src/utils/utils.js +5 -3
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/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/lib/utils/utils.js
CHANGED
|
@@ -321,7 +321,7 @@ const fileSystem = {
|
|
|
321
321
|
exports.fileSystem = fileSystem;
|
|
322
322
|
const foundedTestLog = (app, tests) => {
|
|
323
323
|
const n = tests.length;
|
|
324
|
-
return
|
|
324
|
+
return console.log(app, `✅ We found ${n === 1 ? 'one test' : `${n} tests`} in Testomat.io!`);
|
|
325
325
|
};
|
|
326
326
|
exports.foundedTestLog = foundedTestLog;
|
|
327
327
|
const humanize = text => {
|
|
@@ -399,6 +399,8 @@ function storeRunId(runId) {
|
|
|
399
399
|
function readLatestRunId() {
|
|
400
400
|
try {
|
|
401
401
|
const filePath = path_1.default.join(os_1.default.tmpdir(), `testomatio.latest.run`);
|
|
402
|
+
if (!fs_1.default.existsSync(filePath))
|
|
403
|
+
return null;
|
|
402
404
|
const stats = fs_1.default.statSync(filePath);
|
|
403
405
|
const diff = +new Date() - +stats.mtime;
|
|
404
406
|
const diffHours = diff / 1000 / 60 / 60;
|
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/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
|
/**
|
package/src/utils/utils.js
CHANGED
|
@@ -53,7 +53,7 @@ const parseSuite = suiteTitle => {
|
|
|
53
53
|
*/
|
|
54
54
|
const validateSuiteId = suiteId => {
|
|
55
55
|
if (!suiteId) return null;
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
const match = suiteId.match(SUITE_ID_REGEX);
|
|
58
58
|
return match ? match[0] : null;
|
|
59
59
|
};
|
|
@@ -273,7 +273,7 @@ const fileSystem = {
|
|
|
273
273
|
const foundedTestLog = (app, tests) => {
|
|
274
274
|
const n = tests.length;
|
|
275
275
|
|
|
276
|
-
return
|
|
276
|
+
return console.log(app, `✅ We found ${n === 1 ? 'one test' : `${n} tests`} in Testomat.io!`);
|
|
277
277
|
};
|
|
278
278
|
|
|
279
279
|
const humanize = text => {
|
|
@@ -354,12 +354,14 @@ function storeRunId(runId) {
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
/**
|
|
357
|
-
*
|
|
357
|
+
*
|
|
358
358
|
* @returns {String|null} latest run ID
|
|
359
359
|
*/
|
|
360
360
|
function readLatestRunId() {
|
|
361
361
|
try {
|
|
362
362
|
const filePath = path.join(os.tmpdir(), `testomatio.latest.run`);
|
|
363
|
+
if (!fs.existsSync(filePath)) return null;
|
|
364
|
+
|
|
363
365
|
const stats = fs.statSync(filePath);
|
|
364
366
|
const diff = +new Date() - +stats.mtime;
|
|
365
367
|
const diffHours = diff / 1000 / 60 / 60;
|