@testomatio/reporter 1.1.0-rc.1 → 1.1.0-rc.2
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/README.md +10 -17
- package/lib/adapter/jest.js +7 -8
- package/lib/client.js +10 -3
- package/lib/data-storage.js +2 -2
- package/lib/fileUploader.js +7 -4
- package/lib/reporter-functions.js +1 -10
- package/lib/reporter.js +8 -19
- package/lib/services/artifacts.js +1 -1
- package/lib/services/key-values.js +1 -1
- package/lib/services/logger.js +6 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -65,23 +65,16 @@ yarn add @testomatio/reporter --dev
|
|
|
65
65
|
|
|
66
66
|
### 1️⃣ Attach Reporter to the Test Runner
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
* #### [JUnit](./docs/junit.md#junit)
|
|
79
|
-
* #### [NUnit](./docs/junit.md#nunit)
|
|
80
|
-
* #### [PyTest](./docs/junit.md#pytest)
|
|
81
|
-
* #### [PHPUnit](./docs/junit.md#phpunit)
|
|
82
|
-
* #### [Protractor](./docs/frameworks.md#protractor)
|
|
83
|
-
|
|
84
|
-
or any [other via JUnit](./docs/junit.md) report....
|
|
68
|
+
| | | |
|
|
69
|
+
|--|--|--|
|
|
70
|
+
| [Playwright](./docs/frameworks.md#playwright) | [CodeceptJS](./docs/frameworks.md#CodeceptJS) | [Cypress](./docs/frameworks.md#Cypress) |
|
|
71
|
+
| [Jest](./docs/frameworks.md#Jest) | [Mocha](./docs/frameworks.md#Mocha) | [WebDriverIO](./docs/frameworks.md#WebDriverIO) |
|
|
72
|
+
| [TestCafe](./docs/frameworks.md#TestCafe) | [Detox](./docs/frameworks.md#Detox) | [Codeception](https://github.com/testomatio/php-reporter) |
|
|
73
|
+
| [Newman (Postman)](./docs/frameworks.md#Newman) | [JUnit](./docs/junit.md#junit) | [NUnit](./docs/junit.md#nunit) |
|
|
74
|
+
| [PyTest](./docs/junit.md#pytest) | [PHPUnit](./docs/junit.md#phpunit) | [Protractor](./docs/frameworks.md#protractor) |
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
or **any [other via JUnit](./docs/junit.md)** report....
|
|
85
78
|
|
|
86
79
|
### 2️⃣ Configure Reports
|
|
87
80
|
|
package/lib/adapter/jest.js
CHANGED
|
@@ -4,6 +4,7 @@ const { STATUS, TESTOMAT_TMP_STORAGE_DIR } = require('../constants');
|
|
|
4
4
|
const { parseTest, ansiRegExp, fileSystem } = require('../utils/utils');
|
|
5
5
|
const { services } = require('../services');
|
|
6
6
|
const debug = require('debug')('@testomatio/reporter:adapter-jest');
|
|
7
|
+
const path = require('path');
|
|
7
8
|
|
|
8
9
|
class JestReporter {
|
|
9
10
|
constructor(globalConfig, options) {
|
|
@@ -47,13 +48,11 @@ class JestReporter {
|
|
|
47
48
|
steps = failureMessages[0];
|
|
48
49
|
}
|
|
49
50
|
const testId = parseTest(title);
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
suite_title = result.fullName.replace(result.title, '');
|
|
56
|
-
}
|
|
51
|
+
|
|
52
|
+
// suite titles from most outer to most inner, separated by space
|
|
53
|
+
let fullSuiteTitle = testResult.ancestorTitles?.join(' ');
|
|
54
|
+
// if no suite titles, use file name
|
|
55
|
+
if (!fullSuiteTitle && testResult.testFilePath) fullSuiteTitle = path.basename(testResult.testFilePath);
|
|
57
56
|
|
|
58
57
|
const logs = getTestLogs(result);
|
|
59
58
|
const artifacts = services.artifacts.get(testResult.fullName);
|
|
@@ -65,7 +64,7 @@ class JestReporter {
|
|
|
65
64
|
if (!this._globalConfig.testNamePattern || deducedStatus !== 'skipped') {
|
|
66
65
|
this.client.addTestRun(deducedStatus, {
|
|
67
66
|
test_id: testId,
|
|
68
|
-
suite_title,
|
|
67
|
+
suite_title: fullSuiteTitle,
|
|
69
68
|
error,
|
|
70
69
|
steps,
|
|
71
70
|
title,
|
package/lib/client.js
CHANGED
|
@@ -163,9 +163,16 @@ class Client {
|
|
|
163
163
|
uploadedFiles.push(upload.uploadFileAsBuffer(buffer, fileName, this.uuid));
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
const artifacts = await Promise.all(uploadedFiles);
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
const artifacts = (await Promise.all(uploadedFiles)).filter(n => !!n);
|
|
167
|
+
|
|
168
|
+
if (artifacts.length < uploadedFiles.length) {
|
|
169
|
+
console.log(
|
|
170
|
+
APP_PREFIX,
|
|
171
|
+
chalk.yellow(
|
|
172
|
+
`Some artifacts were not uploaded. ${artifacts.length}/${uploadedFiles.length} artifacts uploaded.`,
|
|
173
|
+
),
|
|
174
|
+
);
|
|
175
|
+
}
|
|
169
176
|
|
|
170
177
|
this.totalUploaded += uploadedFiles.filter(n => n).length;
|
|
171
178
|
|
package/lib/data-storage.js
CHANGED
|
@@ -58,8 +58,6 @@ class DataStorage {
|
|
|
58
58
|
*/
|
|
59
59
|
putData(dataType, data, context = null) {
|
|
60
60
|
if (!dataType || !data) return;
|
|
61
|
-
const dataDirPath = path.join(TESTOMAT_TMP_STORAGE_DIR, dataType);
|
|
62
|
-
fileSystem.createDir(dataDirPath);
|
|
63
61
|
|
|
64
62
|
context = context || this.context || global.testomatioTestTitle || jestHelpers.getIdOfCurrentlyRunningTest();
|
|
65
63
|
if (!context) {
|
|
@@ -69,6 +67,8 @@ class DataStorage {
|
|
|
69
67
|
context = this.#stringToFilename(context);
|
|
70
68
|
|
|
71
69
|
if (this.isFileStorage) {
|
|
70
|
+
const dataDirPath = path.join(TESTOMAT_TMP_STORAGE_DIR, dataType);
|
|
71
|
+
fileSystem.createDir(dataDirPath);
|
|
72
72
|
this.#putDataToFile(dataType, data, context);
|
|
73
73
|
} else {
|
|
74
74
|
this.#putDataToGlobalVar(dataType, data, context);
|
package/lib/fileUploader.js
CHANGED
|
@@ -146,8 +146,13 @@ const uploadUsingS3 = async (filePath, runId) => {
|
|
|
146
146
|
params
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
|
|
150
|
+
const link = await getS3LocationLink(out);
|
|
151
|
+
|
|
152
|
+
debug(`Succesfully uploaded ${filePath} => ${S3_BUCKET}/${Key} | URL: ${link}`);
|
|
153
|
+
|
|
154
|
+
return link;
|
|
155
|
+
}
|
|
151
156
|
catch (e) {
|
|
152
157
|
debug('S3 file uploading error: ', e);
|
|
153
158
|
|
|
@@ -279,8 +284,6 @@ const getS3LocationLink = async (out) => {
|
|
|
279
284
|
|
|
280
285
|
let s3Location = response?.Location;
|
|
281
286
|
|
|
282
|
-
debug('Uploaded response.Location', s3Location);
|
|
283
|
-
|
|
284
287
|
if (!s3Location) {
|
|
285
288
|
// TODO: out: a fallback case - remove after deeper testing
|
|
286
289
|
s3Location = out?.singleUploadResult?.Location;
|
|
@@ -19,7 +19,7 @@ function saveArtifact(data, context = null) {
|
|
|
19
19
|
* @param {...any} args
|
|
20
20
|
*/
|
|
21
21
|
function logMessage(...args) {
|
|
22
|
-
services.logger.
|
|
22
|
+
services.logger.templateLiteralLog(...args);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -38,18 +38,9 @@ function setKeyValue(keyValue) {
|
|
|
38
38
|
services.keyValues.put(keyValue);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
* @param {string} context – test id or test title or suite title + test title
|
|
44
|
-
*/
|
|
45
|
-
function _setStorageContext(context) {
|
|
46
|
-
services.setContext(context);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
41
|
module.exports = {
|
|
50
42
|
artifact: saveArtifact,
|
|
51
43
|
log: logMessage,
|
|
52
44
|
step: addStep,
|
|
53
45
|
keyValue: setKeyValue,
|
|
54
|
-
_setStorageContext,
|
|
55
46
|
};
|
package/lib/reporter.js
CHANGED
|
@@ -1,30 +1,19 @@
|
|
|
1
|
-
const { services } = require('./services');
|
|
2
1
|
const TestomatClient = require('./client');
|
|
3
2
|
const TRConstants = require('./constants');
|
|
4
3
|
|
|
5
|
-
const logger = services.logger;
|
|
6
|
-
|
|
7
|
-
// TODO: should be deprecated, reporter-functions should be used instead
|
|
8
|
-
const log = logger.templateLiteralLog.bind(logger);
|
|
9
|
-
const step = logger.step.bind(logger);
|
|
10
|
-
|
|
11
4
|
const reporterFunctions = require('./reporter-functions');
|
|
12
5
|
|
|
13
6
|
module.exports = {
|
|
14
|
-
//
|
|
15
|
-
logger,
|
|
16
|
-
testomatioLogger:
|
|
17
|
-
|
|
18
|
-
log,
|
|
19
|
-
step,
|
|
20
|
-
TestomatClient,
|
|
21
|
-
TRConstants,
|
|
22
|
-
};
|
|
7
|
+
// TODO: deprecate in future; use log or testomat.log
|
|
8
|
+
logger: reporterFunctions.log,
|
|
9
|
+
testomatioLogger: reporterFunctions.log,
|
|
23
10
|
|
|
24
|
-
module.exports.testomat = {
|
|
25
11
|
artifact: reporterFunctions.artifact,
|
|
26
12
|
log: reporterFunctions.log,
|
|
27
|
-
step: reporterFunctions.step,
|
|
28
13
|
meta: reporterFunctions.keyValue,
|
|
29
|
-
|
|
14
|
+
step: reporterFunctions.step,
|
|
15
|
+
|
|
16
|
+
TestomatClient,
|
|
17
|
+
TRConstants,
|
|
30
18
|
};
|
|
19
|
+
|
package/lib/services/logger.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
|
-
const debug = require('debug')('@testomatio/reporter:logger');
|
|
2
|
+
const debug = require('debug')('@testomatio/reporter:services-logger');
|
|
3
3
|
const { dataStorage } = require('../data-storage');
|
|
4
4
|
|
|
5
5
|
const LOG_METHODS = ['assert', 'debug', 'error', 'info', 'log', 'trace', 'warn'];
|
|
@@ -150,11 +150,12 @@ class Logger {
|
|
|
150
150
|
|
|
151
151
|
const logs = this.#stringifyLogs(...argsArray);
|
|
152
152
|
|
|
153
|
-
// skip logs from testomatio reporter itself
|
|
154
|
-
if (logs.includes('[TESTOMATIO]')) return;
|
|
155
|
-
|
|
156
153
|
const colorizedLogs = chalk[LEVELS[level].color](logs);
|
|
157
|
-
|
|
154
|
+
// do not attach logs from testomatio reporter itself
|
|
155
|
+
if (!logs.includes('[TESTOMATIO]')) {
|
|
156
|
+
dataStorage.putData('log', colorizedLogs);
|
|
157
|
+
}
|
|
158
|
+
|
|
158
159
|
try {
|
|
159
160
|
// level.toLowerCase() represents method name (log, warn, error, etc)
|
|
160
161
|
this.#originalUserLogger[level.toLowerCase()](colorizedLogs);
|