@testomatio/reporter 2.0.1-beta.3 → 2.0.1-beta.5-timestamp
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 +335 -293
- package/lib/adapter/cucumber/current.js +203 -195
- package/lib/adapter/cucumber/legacy.js +155 -130
- package/lib/adapter/cucumber.js +16 -5
- package/lib/adapter/cypress-plugin/index.js +105 -91
- package/lib/adapter/jasmine.js +53 -54
- package/lib/adapter/jest.js +99 -97
- package/lib/adapter/mocha.js +141 -112
- package/lib/adapter/playwright.js +231 -199
- package/lib/adapter/vitest.js +149 -150
- package/lib/adapter/webdriver.js +121 -144
- package/lib/bin/cli.js +211 -229
- package/lib/bin/reportXml.js +52 -51
- package/lib/bin/startTest.js +95 -83
- package/lib/bin/uploadArtifacts.js +61 -56
- package/lib/client.js +465 -424
- package/lib/config.js +23 -18
- package/lib/constants.js +44 -50
- package/lib/data-storage.js +188 -216
- package/lib/junit-adapter/adapter.js +20 -17
- package/lib/junit-adapter/csharp.js +14 -28
- package/lib/junit-adapter/index.js +25 -27
- package/lib/junit-adapter/java.js +53 -41
- package/lib/junit-adapter/javascript.js +27 -30
- package/lib/junit-adapter/python.js +37 -38
- package/lib/junit-adapter/ruby.js +8 -11
- package/lib/output.js +52 -44
- package/lib/pipe/bitbucket.js +230 -223
- package/lib/pipe/csv.js +126 -113
- package/lib/pipe/debug.js +99 -118
- package/lib/pipe/github.js +213 -218
- package/lib/pipe/gitlab.js +206 -183
- package/lib/pipe/html.js +321 -258
- package/lib/pipe/index.js +66 -94
- package/lib/pipe/testomatio.js +474 -429
- package/lib/reporter-functions.js +26 -28
- package/lib/reporter.js +29 -34
- package/lib/services/artifacts.js +51 -55
- package/lib/services/index.js +12 -14
- package/lib/services/key-values.js +53 -56
- package/lib/services/logger.js +245 -226
- package/lib/template/testomatio.hbs +1366 -1026
- package/lib/uploader.js +364 -295
- package/lib/utils/pipe_utils.js +85 -89
- package/lib/utils/utils.js +307 -398
- package/lib/xmlReader.js +532 -525
- package/package.json +21 -64
- package/lib/adapter/codecept.d.ts +0 -2
- package/lib/adapter/cucumber/current.d.ts +0 -14
- package/lib/adapter/cucumber/legacy.d.ts +0 -0
- package/lib/adapter/cucumber.d.ts +0 -2
- package/lib/adapter/cypress-plugin/index.d.ts +0 -2
- package/lib/adapter/jasmine.d.ts +0 -11
- package/lib/adapter/jest.d.ts +0 -13
- package/lib/adapter/mocha.d.ts +0 -2
- package/lib/adapter/nightwatch.d.ts +0 -4
- package/lib/adapter/nightwatch.js +0 -80
- package/lib/adapter/playwright.d.ts +0 -14
- package/lib/adapter/vitest.d.ts +0 -35
- package/lib/adapter/webdriver.d.ts +0 -24
- package/lib/bin/cli.d.ts +0 -2
- package/lib/bin/reportXml.d.ts +0 -2
- package/lib/bin/startTest.d.ts +0 -2
- package/lib/bin/uploadArtifacts.d.ts +0 -2
- package/lib/client.d.ts +0 -76
- package/lib/config.d.ts +0 -1
- package/lib/constants.d.ts +0 -25
- package/lib/data-storage.d.ts +0 -34
- package/lib/junit-adapter/adapter.d.ts +0 -9
- package/lib/junit-adapter/csharp.d.ts +0 -5
- package/lib/junit-adapter/index.d.ts +0 -3
- package/lib/junit-adapter/java.d.ts +0 -5
- package/lib/junit-adapter/javascript.d.ts +0 -4
- package/lib/junit-adapter/python.d.ts +0 -5
- package/lib/junit-adapter/ruby.d.ts +0 -4
- package/lib/output.d.ts +0 -11
- package/lib/package.json +0 -3
- package/lib/pipe/bitbucket.d.ts +0 -25
- package/lib/pipe/csv.d.ts +0 -47
- package/lib/pipe/debug.d.ts +0 -29
- package/lib/pipe/github.d.ts +0 -30
- package/lib/pipe/gitlab.d.ts +0 -25
- package/lib/pipe/html.d.ts +0 -35
- package/lib/pipe/index.d.ts +0 -1
- package/lib/pipe/testomatio.d.ts +0 -71
- package/lib/replay.d.ts +0 -31
- package/lib/replay.js +0 -237
- package/lib/reporter-functions.d.ts +0 -34
- package/lib/reporter.d.ts +0 -232
- package/lib/services/artifacts.d.ts +0 -33
- package/lib/services/index.d.ts +0 -9
- package/lib/services/key-values.d.ts +0 -27
- package/lib/services/logger.d.ts +0 -64
- package/lib/uploader.d.ts +0 -60
- package/lib/utils/pipe_utils.d.ts +0 -41
- package/lib/utils/utils.d.ts +0 -54
- package/lib/xmlReader.d.ts +0 -92
- package/src/adapter/codecept.js +0 -373
- package/src/adapter/cucumber/current.js +0 -228
- package/src/adapter/cucumber/legacy.js +0 -158
- package/src/adapter/cucumber.js +0 -4
- package/src/adapter/cypress-plugin/index.js +0 -110
- package/src/adapter/jasmine.js +0 -60
- package/src/adapter/jest.js +0 -107
- package/src/adapter/mocha.cjs +0 -2
- package/src/adapter/mocha.js +0 -156
- package/src/adapter/nightwatch.js +0 -88
- package/src/adapter/playwright.js +0 -254
- package/src/adapter/vitest.js +0 -183
- package/src/adapter/webdriver.js +0 -142
- package/src/bin/cli.js +0 -348
- package/src/bin/reportXml.js +0 -77
- package/src/bin/startTest.js +0 -124
- package/src/bin/uploadArtifacts.js +0 -91
- package/src/client.js +0 -508
- package/src/config.js +0 -30
- package/src/constants.js +0 -53
- package/src/data-storage.js +0 -204
- package/src/junit-adapter/adapter.js +0 -23
- package/src/junit-adapter/csharp.js +0 -28
- package/src/junit-adapter/index.js +0 -28
- package/src/junit-adapter/java.js +0 -58
- package/src/junit-adapter/javascript.js +0 -31
- package/src/junit-adapter/python.js +0 -42
- package/src/junit-adapter/ruby.js +0 -10
- package/src/output.js +0 -57
- package/src/pipe/bitbucket.js +0 -252
- package/src/pipe/csv.js +0 -140
- package/src/pipe/debug.js +0 -119
- package/src/pipe/github.js +0 -232
- package/src/pipe/gitlab.js +0 -247
- package/src/pipe/html.js +0 -373
- package/src/pipe/index.js +0 -71
- package/src/pipe/testomatio.js +0 -504
- package/src/replay.js +0 -245
- package/src/reporter-functions.js +0 -55
- package/src/reporter.cjs_decprecated +0 -21
- package/src/reporter.js +0 -33
- package/src/services/artifacts.js +0 -59
- package/src/services/index.js +0 -13
- package/src/services/key-values.js +0 -59
- package/src/services/logger.js +0 -315
- package/src/template/emptyData.svg +0 -23
- package/src/template/testomatio.hbs +0 -1081
- package/src/uploader.js +0 -376
- package/src/utils/pipe_utils.js +0 -119
- package/src/utils/utils.js +0 -416
- package/src/xmlReader.js +0 -614
package/lib/adapter/jest.js
CHANGED
|
@@ -1,103 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const constants_js_1 = require("../constants.js");
|
|
10
|
-
const utils_js_1 = require("../utils/utils.js");
|
|
11
|
-
const index_js_1 = require("../services/index.js");
|
|
12
|
-
const path_1 = __importDefault(require("path"));
|
|
13
|
-
const debug_1 = __importDefault(require("debug"));
|
|
14
|
-
const debug = (0, debug_1.default)('@testomatio/reporter:adapter-jest');
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const TestomatClient = require('../client');
|
|
3
|
+
const { STATUS, TESTOMAT_TMP_STORAGE_DIR } = require('../constants');
|
|
4
|
+
const { getTestomatIdFromTestTitle, ansiRegExp, fileSystem } = require('../utils/utils');
|
|
5
|
+
const { services } = require('../services');
|
|
6
|
+
const debug = require('debug')('@testomatio/reporter:adapter-jest');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
|
|
15
9
|
class JestReporter {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this.client.updateRunStatus(status);
|
|
10
|
+
constructor(globalConfig, options) {
|
|
11
|
+
this._globalConfig = globalConfig;
|
|
12
|
+
this._options = options;
|
|
13
|
+
|
|
14
|
+
this.client = new TestomatClient({ apiKey: options?.apiKey });
|
|
15
|
+
this.client.createRun();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
onRunStart() {
|
|
19
|
+
// clear tmp dir
|
|
20
|
+
fileSystem.clearDir(TESTOMAT_TMP_STORAGE_DIR);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// start of test file (including beforeAll)
|
|
24
|
+
onTestStart(testFile) {
|
|
25
|
+
debug('Start running test file:', testFile.path);
|
|
26
|
+
services.setContext(testFile.path);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// start of the test (including beforeEach)
|
|
30
|
+
onTestCaseStart(test, testCase) {
|
|
31
|
+
debug('Start running test:', testCase.fullName);
|
|
32
|
+
services.setContext(testCase.fullName);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// end of test file! (there is also onTestCaseResult listener)
|
|
36
|
+
onTestResult(test, testResult) {
|
|
37
|
+
if (!this.client) return;
|
|
38
|
+
|
|
39
|
+
const { testResults } = testResult;
|
|
40
|
+
for (const result of testResults) {
|
|
41
|
+
let error;
|
|
42
|
+
let steps;
|
|
43
|
+
const { status, title, duration, failureMessages } = result;
|
|
44
|
+
if (failureMessages[0]) {
|
|
45
|
+
let errorMessage = failureMessages[0].replace(ansiRegExp(), '');
|
|
46
|
+
errorMessage = errorMessage.split('\n')[0];
|
|
47
|
+
error = new Error(errorMessage);
|
|
48
|
+
steps = failureMessages[0];
|
|
49
|
+
}
|
|
50
|
+
const testId = getTestomatIdFromTestTitle(title);
|
|
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);
|
|
56
|
+
|
|
57
|
+
const logs = getTestLogs(result);
|
|
58
|
+
const artifacts = services.artifacts.get(result.fullName);
|
|
59
|
+
const keyValues = services.keyValues.get(result.fullName);
|
|
60
|
+
|
|
61
|
+
const deducedStatus = status === 'pending' ? 'skipped' : status;
|
|
62
|
+
// In jest if test is not matched with test name pattern it is considered as skipped.
|
|
63
|
+
// So adding a check if it is skipped for real or because of test pattern
|
|
64
|
+
if (!this._globalConfig.testNamePattern || deducedStatus !== 'skipped') {
|
|
65
|
+
this.client.addTestRun(deducedStatus, {
|
|
66
|
+
test_id: testId,
|
|
67
|
+
suite_title: fullSuiteTitle,
|
|
68
|
+
error,
|
|
69
|
+
steps,
|
|
70
|
+
title,
|
|
71
|
+
time: duration,
|
|
72
|
+
logs,
|
|
73
|
+
manuallyAttachedArtifacts: artifacts,
|
|
74
|
+
meta: keyValues,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
84
77
|
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
onRunComplete(contexts, results) {
|
|
81
|
+
if (!this.client) return;
|
|
82
|
+
|
|
83
|
+
const { numFailedTests } = results;
|
|
84
|
+
const status = numFailedTests === 0 ? STATUS.PASSED : STATUS.FAILED;
|
|
85
|
+
this.client.updateRunStatus(status);
|
|
86
|
+
}
|
|
85
87
|
}
|
|
86
|
-
|
|
88
|
+
|
|
87
89
|
function getTestLogs(testResult) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
90
|
+
const suiteLogsArr = services.logger.getLogs(testResult.testFilePath);
|
|
91
|
+
const suiteLogs = suiteLogsArr ? suiteLogsArr.join('\n').trim() : '';
|
|
92
|
+
const testLogsArr = services.logger.getLogs(testResult.fullName);
|
|
93
|
+
const testLogs = testLogsArr ? testLogsArr.join('\n').trim() : '';
|
|
94
|
+
|
|
95
|
+
let logs = '';
|
|
96
|
+
if (suiteLogs) {
|
|
97
|
+
logs += `${chalk.bold('\t--- Suite ---')}\n${suiteLogs}`;
|
|
98
|
+
}
|
|
99
|
+
if (testLogs) {
|
|
100
|
+
logs += `\n${chalk.bold('\t--- Test ---')}\n${testLogs}`;
|
|
101
|
+
}
|
|
102
|
+
return logs;
|
|
100
103
|
}
|
|
101
|
-
module.exports = JestReporter;
|
|
102
104
|
|
|
103
|
-
module.exports
|
|
105
|
+
module.exports = JestReporter;
|
package/lib/adapter/mocha.js
CHANGED
|
@@ -1,125 +1,154 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
// eslint-disable-next-line global-require, import/no-extraneous-dependencies
|
|
2
|
+
const Mocha = require('mocha');
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const TestomatClient = require('../client');
|
|
5
|
+
const { STATUS, TESTOMAT_TMP_STORAGE_DIR } = require('../constants');
|
|
6
|
+
const { getTestomatIdFromTestTitle, fileSystem } = require('../utils/utils');
|
|
7
|
+
const config = require('../config');
|
|
8
|
+
const { services } = require('../services');
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
EVENT_RUN_BEGIN,
|
|
12
|
+
EVENT_RUN_END,
|
|
13
|
+
EVENT_TEST_FAIL,
|
|
14
|
+
EVENT_TEST_PASS,
|
|
15
|
+
EVENT_TEST_PENDING,
|
|
16
|
+
EVENT_SUITE_BEGIN,
|
|
17
|
+
EVENT_SUITE_END,
|
|
18
|
+
EVENT_TEST_BEGIN,
|
|
19
|
+
EVENT_TEST_END,
|
|
20
|
+
} = Mocha.Runner.constants;
|
|
21
|
+
|
|
14
22
|
function MochaReporter(runner, opts) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
Mocha.reporters.Base.call(this, runner);
|
|
24
|
+
let passes = 0;
|
|
25
|
+
let failures = 0;
|
|
26
|
+
let skipped = 0;
|
|
27
|
+
|
|
28
|
+
const apiKey = opts?.reporterOptions?.apiKey || config.TESTOMATIO;
|
|
29
|
+
|
|
30
|
+
const client = new TestomatClient({ apiKey });
|
|
31
|
+
|
|
32
|
+
runner.on(EVENT_RUN_BEGIN, () => {
|
|
33
|
+
client.createRun();
|
|
34
|
+
|
|
35
|
+
// clear dir with artifacts/logs
|
|
36
|
+
fileSystem.clearDir(TESTOMAT_TMP_STORAGE_DIR);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
runner.on(EVENT_SUITE_BEGIN, async suite => {
|
|
40
|
+
services.setContext(suite.fullTitle());
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
runner.on(EVENT_SUITE_END, async () => {
|
|
44
|
+
services.setContext(null);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
runner.on(EVENT_TEST_BEGIN, async test => {
|
|
48
|
+
services.setContext(test.fullTitle());
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
runner.on(EVENT_TEST_END, async () => {
|
|
52
|
+
services.setContext(null);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
runner.on(EVENT_TEST_PASS, async test => {
|
|
56
|
+
passes += 1;
|
|
57
|
+
|
|
58
|
+
console.log(chalk.bold.green('✔'), test.fullTitle());
|
|
59
|
+
const testId = getTestomatIdFromTestTitle(test.title);
|
|
60
|
+
|
|
61
|
+
const logs = getTestLogs(test);
|
|
62
|
+
const artifacts = services.artifacts.get(test.fullTitle());
|
|
63
|
+
const keyValues = services.keyValues.get(test.fullTitle());
|
|
64
|
+
|
|
65
|
+
client.addTestRun(STATUS.PASSED, {
|
|
66
|
+
test_id: testId,
|
|
67
|
+
suite_title: getSuiteTitle(test),
|
|
68
|
+
title: getTestName(test),
|
|
69
|
+
code: process.env.TESTOMATIO_UPDATE_CODE ? test.body.toString() : '',
|
|
70
|
+
file: getFile(test),
|
|
71
|
+
time: test.duration,
|
|
72
|
+
logs,
|
|
73
|
+
manuallyAttachedArtifacts: artifacts,
|
|
74
|
+
meta: keyValues,
|
|
26
75
|
});
|
|
27
|
-
|
|
28
|
-
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
runner.on(EVENT_TEST_PENDING, test => {
|
|
79
|
+
skipped += 1;
|
|
80
|
+
console.log('skip: %s', test.fullTitle());
|
|
81
|
+
const testId = getTestomatIdFromTestTitle(test.title);
|
|
82
|
+
client.addTestRun(STATUS.SKIPPED, {
|
|
83
|
+
title: getTestName(test),
|
|
84
|
+
suite_title: getSuiteTitle(test),
|
|
85
|
+
code: process.env.TESTOMATIO_UPDATE_CODE ? test.body.toString() : '',
|
|
86
|
+
file: getFile(test),
|
|
87
|
+
test_id: testId,
|
|
88
|
+
time: test.duration,
|
|
29
89
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
suite_title: getSuiteTitle(test),
|
|
49
|
-
title: getTestName(test),
|
|
50
|
-
code: process.env.TESTOMATIO_UPDATE_CODE ? test.body.toString() : '',
|
|
51
|
-
file: getFile(test),
|
|
52
|
-
time: test.duration,
|
|
53
|
-
logs,
|
|
54
|
-
manuallyAttachedArtifacts: artifacts,
|
|
55
|
-
meta: keyValues,
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
runner.on(EVENT_TEST_PENDING, test => {
|
|
59
|
-
skipped += 1;
|
|
60
|
-
console.log('skip: %s', test.fullTitle());
|
|
61
|
-
const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(test.title);
|
|
62
|
-
client.addTestRun(constants_js_1.STATUS.SKIPPED, {
|
|
63
|
-
title: getTestName(test),
|
|
64
|
-
suite_title: getSuiteTitle(test),
|
|
65
|
-
code: process.env.TESTOMATIO_UPDATE_CODE ? test.body.toString() : '',
|
|
66
|
-
file: getFile(test),
|
|
67
|
-
test_id: testId,
|
|
68
|
-
time: test.duration,
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
runner.on(EVENT_TEST_FAIL, async (test, err) => {
|
|
72
|
-
failures += 1;
|
|
73
|
-
console.log(picocolors_1.default.bold(picocolors_1.default.red('✖')), test.fullTitle(), picocolors_1.default.gray(err.message));
|
|
74
|
-
const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(test.title);
|
|
75
|
-
const logs = getTestLogs(test);
|
|
76
|
-
client.addTestRun(constants_js_1.STATUS.FAILED, {
|
|
77
|
-
error: err,
|
|
78
|
-
suite_title: getSuiteTitle(test),
|
|
79
|
-
file: getFile(test),
|
|
80
|
-
test_id: testId,
|
|
81
|
-
title: getTestName(test),
|
|
82
|
-
code: process.env.TESTOMATIO_UPDATE_CODE ? test.body.toString() : '',
|
|
83
|
-
time: test.duration,
|
|
84
|
-
logs,
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
runner.on(EVENT_RUN_END, () => {
|
|
88
|
-
const status = failures === 0 ? constants_js_1.STATUS.PASSED : constants_js_1.STATUS.FAILED;
|
|
89
|
-
console.log(picocolors_1.default.bold(status), `${passes} passed, ${failures} failed, ${skipped} skipped`);
|
|
90
|
-
// @ts-ignore
|
|
91
|
-
client.updateRunStatus(status);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
runner.on(EVENT_TEST_FAIL, async (test, err) => {
|
|
93
|
+
failures += 1;
|
|
94
|
+
console.log(chalk.bold.red('✖'), test.fullTitle(), chalk.gray(err.message));
|
|
95
|
+
const testId = getTestomatIdFromTestTitle(test.title);
|
|
96
|
+
|
|
97
|
+
const logs = getTestLogs(test);
|
|
98
|
+
|
|
99
|
+
client.addTestRun(STATUS.FAILED, {
|
|
100
|
+
error: err,
|
|
101
|
+
suite_title: getSuiteTitle(test),
|
|
102
|
+
file: getFile(test),
|
|
103
|
+
test_id: testId,
|
|
104
|
+
title: getTestName(test),
|
|
105
|
+
code: process.env.TESTOMATIO_UPDATE_CODE ? test.body.toString() : '',
|
|
106
|
+
time: test.duration,
|
|
107
|
+
logs,
|
|
92
108
|
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
runner.on(EVENT_RUN_END, () => {
|
|
112
|
+
const status = failures === 0 ? STATUS.PASSED : STATUS.FAILED;
|
|
113
|
+
console.log(chalk.bold(status), `${passes} passed, ${failures} failed, ${skipped} skipped`);
|
|
114
|
+
client.updateRunStatus(status);
|
|
115
|
+
});
|
|
93
116
|
}
|
|
117
|
+
|
|
94
118
|
function getTestLogs(test) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
119
|
+
const suiteLogsArr = services.logger.getLogs(test.parent.fullTitle());
|
|
120
|
+
const suiteLogs = suiteLogsArr ? suiteLogsArr.join('\n').trim() : '';
|
|
121
|
+
const testLogsArr = services.logger.getLogs(test.fullTitle());
|
|
122
|
+
const testLogs = testLogsArr ? testLogsArr.join('\n').trim() : '';
|
|
123
|
+
|
|
124
|
+
let logs = '';
|
|
125
|
+
if (suiteLogs) {
|
|
126
|
+
logs += `${chalk.bold('\t--- BeforeSuite ---')}\n${suiteLogs}`;
|
|
127
|
+
}
|
|
128
|
+
if (testLogs) {
|
|
129
|
+
logs += `\n${chalk.bold('\t--- Test ---')}\n${testLogs}`;
|
|
130
|
+
}
|
|
131
|
+
return logs;
|
|
107
132
|
}
|
|
133
|
+
|
|
134
|
+
// To have this reporter "extend" a built-in reporter uncomment the following line:
|
|
135
|
+
Mocha.utils.inherits(MochaReporter, Mocha.reporters.Spec);
|
|
136
|
+
|
|
137
|
+
module.exports = MochaReporter;
|
|
138
|
+
|
|
108
139
|
function getSuiteTitle(test, pathArr = []) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
140
|
+
if (test.parent.parent) getSuiteTitle(test.parent, pathArr);
|
|
141
|
+
|
|
142
|
+
pathArr.push(test.parent.title);
|
|
143
|
+
|
|
144
|
+
return pathArr.filter(t => !!t)[0];
|
|
113
145
|
}
|
|
146
|
+
|
|
114
147
|
function getFile(test) {
|
|
115
|
-
|
|
148
|
+
return test.parent.file?.replace(process.cwd(), '');
|
|
116
149
|
}
|
|
150
|
+
|
|
117
151
|
function getTestName(test) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return test.title;
|
|
152
|
+
if (process.env.TESTOMATIO_CREATE === 'fulltitle') return test.fullTitle();
|
|
153
|
+
return test.title;
|
|
121
154
|
}
|
|
122
|
-
// To have this reporter "extend" a built-in reporter uncomment the following line:
|
|
123
|
-
// @ts-ignore
|
|
124
|
-
mocha_1.default.utils.inherits(MochaReporter, mocha_1.default.reporters.Spec);
|
|
125
|
-
module.exports = MochaReporter;
|