@testomatio/reporter 1.1.0-beta-2 → 1.2.0-beta-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/_ArtifactStorageOld.js +142 -0
- package/lib/adapter/codecept.js +2 -2
- package/lib/adapter/cucumber/current.js +3 -3
- package/lib/adapter/cucumber/legacy.js +2 -2
- package/lib/adapter/jest.js +16 -2
- package/lib/adapter/mocha.js +43 -15
- package/lib/adapter/playwright.js +21 -33
- package/lib/artifactStorage.js +25 -0
- package/lib/client.js +21 -18
- package/lib/constants.js +13 -4
- package/lib/{storages/data-storage.js → dataStorage.js} +47 -122
- package/lib/{storages/logger.js → logger.js} +33 -4
- package/lib/pipe/html.js +187 -0
- package/lib/pipe/index.js +2 -0
- package/lib/reporter.js +4 -9
- package/lib/template/real-data-example.js +47 -0
- package/lib/template/template.hbs +249 -0
- package/lib/template/testomatio.hbs +720 -0
- package/lib/utils/utils.js +0 -14
- package/package.json +2 -1
- package/lib/reporter-functions.js +0 -43
- package/lib/storages/artifact-storage.js +0 -70
- package/lib/storages/key-value-storage.js +0 -58
package/lib/utils/utils.js
CHANGED
|
@@ -290,19 +290,6 @@ function removeColorCodes(input) {
|
|
|
290
290
|
return input.replace(/\x1b\[[0-9;]*m/g, '');
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
const jestHelpers = {
|
|
294
|
-
getIdOfCurrentlyRunningTest: () => {
|
|
295
|
-
if (!process.env.JEST_WORKER_ID) return null;
|
|
296
|
-
try {
|
|
297
|
-
// @ts-expect-error "expect" could only be defined inside Jest environement (forbidden to import it outside)
|
|
298
|
-
// eslint-disable-next-line no-undef
|
|
299
|
-
if (expect && expect?.getState()?.currentTestName) return parseTest(expect?.getState()?.currentTestName);
|
|
300
|
-
} catch (e) {
|
|
301
|
-
return null;
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
};
|
|
305
|
-
|
|
306
293
|
module.exports = {
|
|
307
294
|
isSameTest,
|
|
308
295
|
fetchSourceCode,
|
|
@@ -312,7 +299,6 @@ module.exports = {
|
|
|
312
299
|
fetchFilesFromStackTrace,
|
|
313
300
|
fileSystem,
|
|
314
301
|
getCurrentDateTime,
|
|
315
|
-
jestHelpers,
|
|
316
302
|
specificTestInfo,
|
|
317
303
|
isValidUrl,
|
|
318
304
|
ansiRegExp,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testomatio/reporter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-beta-1",
|
|
4
4
|
"description": "Testomatio Reporter Client",
|
|
5
5
|
"main": "./lib/reporter.js",
|
|
6
6
|
"typings": "typings/index.d.ts",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"dotenv": "^16.0.1",
|
|
22
22
|
"fast-xml-parser": "^4.0.8",
|
|
23
23
|
"glob": "^10.3",
|
|
24
|
+
"handlebars": "^4.7.8",
|
|
24
25
|
"has-flag": "^5.0.1",
|
|
25
26
|
"humanize-duration": "^3.27.3",
|
|
26
27
|
"is-valid-path": "^0.1.1",
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const logger = require('./storages/logger');
|
|
2
|
-
const artifactStorage = require('./storages/artifact-storage');
|
|
3
|
-
const keyValueStorage = require('./storages/key-value-storage');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Stores path to file as artifact and uploads it to the S3 storage
|
|
7
|
-
* @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
|
|
8
|
-
*/
|
|
9
|
-
function saveArtifact(data, context = null) {
|
|
10
|
-
if (!data) return;
|
|
11
|
-
artifactStorage.put(data, context);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Attach log message(s) to the test report
|
|
16
|
-
* @param {...any} args
|
|
17
|
-
*/
|
|
18
|
-
function logMessage(...args) {
|
|
19
|
-
logger.log(...args);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Similar to "log" function but marks message in report as a step
|
|
24
|
-
* @param {*} message
|
|
25
|
-
*/
|
|
26
|
-
function addStep(message) {
|
|
27
|
-
logger.step(message);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Add key-value pair(s) to the test report
|
|
32
|
-
* @param {*} keyValue
|
|
33
|
-
*/
|
|
34
|
-
function setKeyValue(keyValue) {
|
|
35
|
-
keyValueStorage.put(keyValue);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
module.exports = {
|
|
39
|
-
artifact: saveArtifact,
|
|
40
|
-
log: logMessage,
|
|
41
|
-
step: addStep,
|
|
42
|
-
keyValue: setKeyValue,
|
|
43
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
const debug = require('debug')('@testomatio/reporter:artifact-storage');
|
|
2
|
-
const DataStorage = require('./data-storage');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Artifact storage is supposed to store file paths
|
|
6
|
-
*/
|
|
7
|
-
class ArtifactStorage {
|
|
8
|
-
|
|
9
|
-
// there is autocompletion for the class methods if implemented singleton this way
|
|
10
|
-
constructor() {
|
|
11
|
-
this.dataStorage = new DataStorage('artifact');
|
|
12
|
-
|
|
13
|
-
// singleton
|
|
14
|
-
if (!ArtifactStorage.instance) {
|
|
15
|
-
ArtifactStorage.instance = this;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// singleton
|
|
20
|
-
static getInstance() {
|
|
21
|
-
if (!ArtifactStorage.instance) {
|
|
22
|
-
ArtifactStorage.instance = new ArtifactStorage();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return ArtifactStorage.instance;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Stores path to file as artifact and uploads it to the S3 storage
|
|
30
|
-
* @param {string | {path: string, type: string, name: string}} data - path to file or object with path, type and name
|
|
31
|
-
* @param {*} context testId or test title
|
|
32
|
-
*/
|
|
33
|
-
put(data, context = null) {
|
|
34
|
-
if (!data) return;
|
|
35
|
-
debug('Save artifact:', data);
|
|
36
|
-
this.dataStorage.putData(data, context);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Returns list of artifacts to upload
|
|
41
|
-
* @param {*} context testId or test context from test runner
|
|
42
|
-
* @returns {string | {path: string, type: string, name: string}[]}
|
|
43
|
-
*/
|
|
44
|
-
get(context) {
|
|
45
|
-
if (!context) return null;
|
|
46
|
-
|
|
47
|
-
// array of any data
|
|
48
|
-
let artifacts = this.dataStorage.getData(context);
|
|
49
|
-
if (!artifacts || !artifacts.length) return null;
|
|
50
|
-
|
|
51
|
-
artifacts = artifacts.map(artifactData => {
|
|
52
|
-
// artifact could be an object ({type, path, name} props) or string
|
|
53
|
-
let artifact;
|
|
54
|
-
try {
|
|
55
|
-
artifact = JSON.parse(artifactData);
|
|
56
|
-
} catch (e) {
|
|
57
|
-
artifact = artifactData;
|
|
58
|
-
}
|
|
59
|
-
return artifact;
|
|
60
|
-
});
|
|
61
|
-
artifacts = artifacts.filter(artifact => !!artifact);
|
|
62
|
-
return artifacts.length ? artifacts : null;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
ArtifactStorage.instance = null;
|
|
67
|
-
|
|
68
|
-
// const artifactStorage = ArtifactStorage.getInstance();
|
|
69
|
-
const artifactStorage = new ArtifactStorage();
|
|
70
|
-
module.exports = artifactStorage;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const debug = require('debug')('@testomatio/reporter:key-value-storage');
|
|
2
|
-
const DataStorage = require('./data-storage');
|
|
3
|
-
|
|
4
|
-
class KeyValueStorage {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.dataStorage = new DataStorage('keyvalue');
|
|
7
|
-
|
|
8
|
-
// singleton
|
|
9
|
-
if (!KeyValueStorage.instance) {
|
|
10
|
-
KeyValueStorage.instance = this;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Stores key-value pair and passes it to reporter
|
|
16
|
-
* @param {{key: string}} keyValue - key-value pair(s) as object
|
|
17
|
-
* @param {*} context testId or test title
|
|
18
|
-
*/
|
|
19
|
-
put(keyValue, context = null) {
|
|
20
|
-
if (!keyValue) return;
|
|
21
|
-
this.dataStorage.putData(keyValue, context);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
#isKeyValueObject(smth) {
|
|
25
|
-
return smth && typeof smth === 'object' && !Array.isArray(smth) && smth !== null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Returns key-values pairs for the test as object
|
|
30
|
-
* @param {*} context testId or test context from test runner
|
|
31
|
-
* @returns {Object} key-values pairs as object
|
|
32
|
-
*/
|
|
33
|
-
get(context) {
|
|
34
|
-
if (!context) return null;
|
|
35
|
-
|
|
36
|
-
const keyValuesList = this.dataStorage.getData(context);
|
|
37
|
-
if (!keyValuesList || !keyValuesList?.length) return null;
|
|
38
|
-
|
|
39
|
-
const keyValues = {};
|
|
40
|
-
for (const keyValue of keyValuesList) {
|
|
41
|
-
if (this.#isKeyValueObject(keyValue)) {
|
|
42
|
-
Object.assign(keyValues, keyValue);
|
|
43
|
-
} else if (typeof keyValue === 'string') {
|
|
44
|
-
try {
|
|
45
|
-
Object.assign(keyValues, JSON.parse(keyValue));
|
|
46
|
-
} catch (e) {
|
|
47
|
-
debug(`Error parsing key-values for test ${context}`, keyValue);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return Object.keys(keyValues).length ? keyValues : null;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
KeyValueStorage.instance = null;
|
|
57
|
-
|
|
58
|
-
module.exports = new KeyValueStorage();
|