@testomatio/reporter 0.7.3 → 0.7.5-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/Changelog.md +4 -0
- package/lib/adapter/mocha.js +13 -4
- package/lib/util.js +2 -0
- package/package.json +1 -1
package/Changelog.md
CHANGED
package/lib/adapter/mocha.js
CHANGED
|
@@ -4,14 +4,13 @@ const TestomatClient = require('../client');
|
|
|
4
4
|
const TRConstants = require('../constants');
|
|
5
5
|
const { parseTest } = require('../util');
|
|
6
6
|
|
|
7
|
-
const { EVENT_RUN_BEGIN, EVENT_RUN_END, EVENT_TEST_FAIL, EVENT_TEST_PASS } = Mocha.Runner.constants;
|
|
7
|
+
const { EVENT_RUN_BEGIN, EVENT_RUN_END, EVENT_TEST_FAIL, EVENT_TEST_PASS, EVENT_TEST_PENDING } = Mocha.Runner.constants;
|
|
8
8
|
|
|
9
9
|
function MochaReporter(runner, opts) {
|
|
10
10
|
Mocha.reporters.Base.call(this, runner);
|
|
11
|
-
let passes = 0;
|
|
12
|
-
let failures = 0;
|
|
11
|
+
let passes = 0, failures = 0, skipped = 0;
|
|
13
12
|
|
|
14
|
-
const
|
|
13
|
+
const apiKey = opts?.reporterOptions?.apiKey || process.env['TESTOMATIO'];
|
|
15
14
|
|
|
16
15
|
if (!apiKey) {
|
|
17
16
|
console.log('TESTOMATIO key is empty, ignoring reports');
|
|
@@ -33,6 +32,16 @@ function MochaReporter(runner, opts) {
|
|
|
33
32
|
});
|
|
34
33
|
});
|
|
35
34
|
|
|
35
|
+
runner.on(EVENT_TEST_PENDING, test => {
|
|
36
|
+
skipped += 1;
|
|
37
|
+
console.log('skip: %s', test.fullTitle());
|
|
38
|
+
const testId = parseTest(test.title);
|
|
39
|
+
client.addTestRun(testId, TRConstants.SKIPPED, {
|
|
40
|
+
title: test.title,
|
|
41
|
+
time: test.duration,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
36
45
|
runner.on(EVENT_TEST_FAIL, (test, err) => {
|
|
37
46
|
failures += 1;
|
|
38
47
|
console.log('fail: %s -- error: %s', test.fullTitle(), err.message);
|
package/lib/util.js
CHANGED
|
@@ -79,6 +79,8 @@ const fetchSourceCodeFromStackTrace = (stack = '') => {
|
|
|
79
79
|
const prepend = 3;
|
|
80
80
|
const source = fetchSourceCode(fs.readFileSync(file).toString(), { line, prepend, limit: 7 })
|
|
81
81
|
|
|
82
|
+
if (!source) return '';
|
|
83
|
+
|
|
82
84
|
return source.split('\n')
|
|
83
85
|
.map((l, i) => {
|
|
84
86
|
if (i === prepend) return `${line} > ${chalk.bold(l)}`;
|