@testomatio/reporter 1.1.0-rc.1 → 1.1.0
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 +5 -15
- package/lib/adapter/jest.js +7 -8
- package/lib/data-storage.js +2 -2
- 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,21 +65,11 @@ yarn add @testomatio/reporter --dev
|
|
|
65
65
|
|
|
66
66
|
### 1️⃣ Attach Reporter to the Test Runner
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
* #### [WebDriverIO](./docs/frameworks.md#WebDriverIO)
|
|
74
|
-
* #### [TestCafe](./docs/frameworks.md#TestCafe)
|
|
75
|
-
* #### [Detox](./docs/frameworks.md#Detox)
|
|
76
|
-
* #### [Codeception](https://github.com/testomatio/php-reporter)
|
|
77
|
-
* #### [Newman (Postman)](./docs/frameworks.md#Newman)
|
|
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)
|
|
68
|
+
| [Playwright](./docs/frameworks.md#playwright) | [CodeceptJS](./docs/frameworks.md#CodeceptJS) | [Cypress](./docs/frameworks.md#Cypress) |
|
|
69
|
+
| [Jest](./docs/frameworks.md#Jest) | [Mocha](./docs/frameworks.md#Mocha) | [WebDriverIO](./docs/frameworks.md#WebDriverIO) |
|
|
70
|
+
| [TestCafe](./docs/frameworks.md#TestCafe) | [Detox](./docs/frameworks.md#Detox) | [Codeception](https://github.com/testomatio/php-reporter) |
|
|
71
|
+
| [Newman (Postman)](./docs/frameworks.md#Newman) | [JUnit](./docs/junit.md#junit) | [NUnit](./docs/junit.md#nunit) |
|
|
72
|
+
| [PyTest](./docs/junit.md#pytest) | [PHPUnit](./docs/junit.md#phpunit) | [Protractor](./docs/frameworks.md#protractor) |
|
|
83
73
|
|
|
84
74
|
or any [other via JUnit](./docs/junit.md) report....
|
|
85
75
|
|
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/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);
|
|
@@ -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);
|