@testomatio/reporter 2.0.1-beta-ignore-xml → 2.1.0-beta-nightwatch
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/nightwatch.d.ts +4 -0
- package/lib/adapter/nightwatch.js +80 -0
- package/lib/client.js +1 -1
- package/lib/config.js +2 -2
- package/lib/pipe/html.d.ts +1 -0
- package/lib/pipe/html.js +1 -0
- package/lib/pipe/testomatio.d.ts +1 -1
- package/package.json +2 -1
- package/src/adapter/nightwatch.js +88 -0
- package/src/client.js +1 -1
- package/src/config.js +2 -2
- package/src/pipe/html.js +2 -0
- package/src/xmlReader.js +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const client_js_1 = __importDefault(require("../client.js"));
|
|
7
|
+
const config_js_1 = require("../config.js");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const utils_js_1 = require("../utils/utils.js");
|
|
10
|
+
const apiKey = config_js_1.config.TESTOMATIO;
|
|
11
|
+
const client = new client_js_1.default({ apiKey });
|
|
12
|
+
module.exports = {
|
|
13
|
+
write: async (results, options, done) => {
|
|
14
|
+
await client.createRun();
|
|
15
|
+
const testFiles = results.modules;
|
|
16
|
+
for (const fileName in testFiles) {
|
|
17
|
+
// in nightwatch: object containing tests from a single file
|
|
18
|
+
const testModule = testFiles[fileName];
|
|
19
|
+
// passed and failed tests (tests with assertions)
|
|
20
|
+
const completedTests = testModule.completed;
|
|
21
|
+
// skipped tests (skipped by user or tests without assertions)
|
|
22
|
+
const skippedTests = testModule.skipped;
|
|
23
|
+
const tags = testModule.tags || [];
|
|
24
|
+
// if test file contains multiple suites, the last suite name is used as a name 🤷♂️
|
|
25
|
+
// no other places which contain suite name (even inside test object)
|
|
26
|
+
const suiteTitle = testModule.name;
|
|
27
|
+
for (const testTitle in completedTests) {
|
|
28
|
+
const test = completedTests[testTitle];
|
|
29
|
+
let status;
|
|
30
|
+
switch (test.status) {
|
|
31
|
+
case 'pass':
|
|
32
|
+
status = constants_1.STATUS.PASSED;
|
|
33
|
+
break;
|
|
34
|
+
case 'fail':
|
|
35
|
+
status = constants_1.STATUS.FAILED;
|
|
36
|
+
break;
|
|
37
|
+
// probably not required (because skipped tests are in separate array), but just in case
|
|
38
|
+
case 'skip':
|
|
39
|
+
status = constants_1.STATUS.SKIPPED;
|
|
40
|
+
console.info('Skipped test is in completed tests array:', test, 'Not expected behavior.');
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
console.error('Test status processing error:', test.status);
|
|
44
|
+
}
|
|
45
|
+
const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(testTitle);
|
|
46
|
+
client.addTestRun(status, {
|
|
47
|
+
error: { name: test.assertions?.[0]?.name, message: test.assertions?.[0]?.message, stack: test.stackTrace },
|
|
48
|
+
file: testModule.modulePath?.replace(process.cwd(), ''),
|
|
49
|
+
message: test.assertions?.[0]?.message,
|
|
50
|
+
rid: `${testModule.uuid || ''}_${testTitle || ''}`,
|
|
51
|
+
stack: test.stackTrace,
|
|
52
|
+
suite_title: suiteTitle,
|
|
53
|
+
tags,
|
|
54
|
+
test_id: testId,
|
|
55
|
+
time: test.timeMs,
|
|
56
|
+
title: testTitle,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// just array with skipped tests titles, no any other info
|
|
60
|
+
for (const testTitle of skippedTests) {
|
|
61
|
+
client.addTestRun(constants_1.STATUS.SKIPPED, {
|
|
62
|
+
suite_title: suiteTitle,
|
|
63
|
+
tags,
|
|
64
|
+
rid: `${testModule.uuid || ''}_${testTitle || ''}`,
|
|
65
|
+
title: testTitle,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* @type {'passed' | 'failed' | 'finished'}
|
|
71
|
+
*/
|
|
72
|
+
let runStatus = 'finished';
|
|
73
|
+
if (results.failed)
|
|
74
|
+
runStatus = 'failed';
|
|
75
|
+
else if (results.passed)
|
|
76
|
+
runStatus = 'passed';
|
|
77
|
+
await client.updateRunStatus(runStatus);
|
|
78
|
+
done();
|
|
79
|
+
},
|
|
80
|
+
};
|
package/lib/client.js
CHANGED
|
@@ -98,7 +98,7 @@ class Client {
|
|
|
98
98
|
}
|
|
99
99
|
try {
|
|
100
100
|
const filterPipe = this.pipes.find(p => p.constructor.name.toLowerCase() === `${pipe.toLowerCase()}pipe`);
|
|
101
|
-
if (!filterPipe
|
|
101
|
+
if (!filterPipe?.isEnabled) {
|
|
102
102
|
// TODO:for the future for the another pipes
|
|
103
103
|
console.warn(constants_js_1.APP_PREFIX, `At the moment processing is available only for the "testomatio" key. Example: "testomatio:tag-name=xxx"`);
|
|
104
104
|
return;
|
package/lib/config.js
CHANGED
|
@@ -9,10 +9,10 @@ const debug_1 = __importDefault(require("debug"));
|
|
|
9
9
|
const debug = (0, debug_1.default)('@testomatio/reporter:config');
|
|
10
10
|
/* for possibility to use multiple env files (reading different paths)
|
|
11
11
|
const envFileVars = dotenv.config({ path: '.env' }).parsed; */
|
|
12
|
-
if (process.env.TESTOMATIO_API_KEY) {
|
|
12
|
+
if (process.env.TESTOMATIO_API_KEY && !process.env.TESTOMATIO) {
|
|
13
13
|
process.env.TESTOMATIO = process.env.TESTOMATIO_API_KEY;
|
|
14
14
|
}
|
|
15
|
-
if (process.env.TESTOMATIO_TOKEN) {
|
|
15
|
+
if (process.env.TESTOMATIO_TOKEN && !process.env.TESTOMATIO) {
|
|
16
16
|
process.env.TESTOMATIO = process.env.TESTOMATIO_TOKEN;
|
|
17
17
|
}
|
|
18
18
|
if (process.env.TESTOMATIO === 'undefined')
|
package/lib/pipe/html.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ declare class HtmlPipe {
|
|
|
15
15
|
templateFolderPath: string;
|
|
16
16
|
templateHtmlPath: string;
|
|
17
17
|
createRun(): Promise<void>;
|
|
18
|
+
prepareRun(): Promise<void>;
|
|
18
19
|
updateRun(): void;
|
|
19
20
|
/**
|
|
20
21
|
* Add test data to the result array for saving. As a result of this function, we get a result object to save.
|
package/lib/pipe/html.js
CHANGED
package/lib/pipe/testomatio.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testomatio/reporter",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0-beta-nightwatch",
|
|
4
4
|
"description": "Testomatio Reporter Client",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18"
|
|
@@ -123,6 +123,7 @@
|
|
|
123
123
|
"./lib/adapter/mocha/mocha.js": "./lib/adapter/mocha.js",
|
|
124
124
|
"./mocha": "./lib/adapter/mocha.js",
|
|
125
125
|
"./lib/adapter/playwright.js": "./lib/adapter/playwright.js",
|
|
126
|
+
"./nightwatch": "./lib/adapter/nightwatch.js",
|
|
126
127
|
"./playwright": "./lib/adapter/playwright.js",
|
|
127
128
|
"./vitest": "./lib/adapter/vitest.js",
|
|
128
129
|
"./lib/adapter/webdriver.js": "./lib/adapter/webdriver.js",
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import TestomatClient from '../client.js';
|
|
2
|
+
import { config } from '../config.js';
|
|
3
|
+
import { STATUS } from '../constants';
|
|
4
|
+
import { getTestomatIdFromTestTitle } from '../utils/utils.js';
|
|
5
|
+
|
|
6
|
+
const apiKey = config.TESTOMATIO;
|
|
7
|
+
const client = new TestomatClient({ apiKey });
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
write: async (results, options, done) => {
|
|
11
|
+
await client.createRun();
|
|
12
|
+
|
|
13
|
+
const testFiles = results.modules;
|
|
14
|
+
|
|
15
|
+
for (const fileName in testFiles) {
|
|
16
|
+
// in nightwatch: object containing tests from a single file
|
|
17
|
+
const testModule = testFiles[fileName];
|
|
18
|
+
|
|
19
|
+
// passed and failed tests (tests with assertions)
|
|
20
|
+
const completedTests = testModule.completed;
|
|
21
|
+
|
|
22
|
+
// skipped tests (skipped by user or tests without assertions)
|
|
23
|
+
const skippedTests = testModule.skipped;
|
|
24
|
+
|
|
25
|
+
const tags = testModule.tags || [];
|
|
26
|
+
|
|
27
|
+
// if test file contains multiple suites, the last suite name is used as a name 🤷♂️
|
|
28
|
+
// no other places which contain suite name (even inside test object)
|
|
29
|
+
const suiteTitle = testModule.name;
|
|
30
|
+
|
|
31
|
+
for (const testTitle in completedTests) {
|
|
32
|
+
const test = completedTests[testTitle];
|
|
33
|
+
let status;
|
|
34
|
+
switch (test.status) {
|
|
35
|
+
case 'pass':
|
|
36
|
+
status = STATUS.PASSED;
|
|
37
|
+
break;
|
|
38
|
+
case 'fail':
|
|
39
|
+
status = STATUS.FAILED;
|
|
40
|
+
break;
|
|
41
|
+
// probably not required (because skipped tests are in separate array), but just in case
|
|
42
|
+
case 'skip':
|
|
43
|
+
status = STATUS.SKIPPED;
|
|
44
|
+
console.info('Skipped test is in completed tests array:', test, 'Not expected behavior.');
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
console.error('Test status processing error:', test.status);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const testId = getTestomatIdFromTestTitle(testTitle);
|
|
51
|
+
|
|
52
|
+
client.addTestRun(status, {
|
|
53
|
+
error: { name: test.assertions?.[0]?.name, message: test.assertions?.[0]?.message, stack: test.stackTrace },
|
|
54
|
+
file: testModule.modulePath?.replace(process.cwd(), ''),
|
|
55
|
+
message: test.assertions?.[0]?.message,
|
|
56
|
+
rid: `${testModule.uuid || ''}_${testTitle || ''}`,
|
|
57
|
+
stack: test.stackTrace,
|
|
58
|
+
suite_title: suiteTitle,
|
|
59
|
+
tags,
|
|
60
|
+
test_id: testId,
|
|
61
|
+
time: test.timeMs,
|
|
62
|
+
title: testTitle,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// just array with skipped tests titles, no any other info
|
|
67
|
+
for (const testTitle of skippedTests) {
|
|
68
|
+
client.addTestRun(STATUS.SKIPPED, {
|
|
69
|
+
suite_title: suiteTitle,
|
|
70
|
+
tags,
|
|
71
|
+
rid: `${testModule.uuid || ''}_${testTitle || ''}`,
|
|
72
|
+
title: testTitle,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @type {'passed' | 'failed' | 'finished'}
|
|
79
|
+
*/
|
|
80
|
+
let runStatus = 'finished';
|
|
81
|
+
if (results.failed) runStatus = 'failed';
|
|
82
|
+
else if (results.passed) runStatus = 'passed';
|
|
83
|
+
|
|
84
|
+
await client.updateRunStatus(runStatus);
|
|
85
|
+
|
|
86
|
+
done();
|
|
87
|
+
},
|
|
88
|
+
};
|
package/src/client.js
CHANGED
|
@@ -79,7 +79,7 @@ class Client {
|
|
|
79
79
|
try {
|
|
80
80
|
const filterPipe = this.pipes.find(p => p.constructor.name.toLowerCase() === `${pipe.toLowerCase()}pipe`);
|
|
81
81
|
|
|
82
|
-
if (!filterPipe
|
|
82
|
+
if (!filterPipe?.isEnabled) {
|
|
83
83
|
// TODO:for the future for the another pipes
|
|
84
84
|
console.warn(
|
|
85
85
|
APP_PREFIX,
|
package/src/config.js
CHANGED
|
@@ -6,10 +6,10 @@ const debug = createDebugMessages('@testomatio/reporter:config');
|
|
|
6
6
|
/* for possibility to use multiple env files (reading different paths)
|
|
7
7
|
const envFileVars = dotenv.config({ path: '.env' }).parsed; */
|
|
8
8
|
|
|
9
|
-
if (process.env.TESTOMATIO_API_KEY) {
|
|
9
|
+
if (process.env.TESTOMATIO_API_KEY && !process.env.TESTOMATIO) {
|
|
10
10
|
process.env.TESTOMATIO = process.env.TESTOMATIO_API_KEY;
|
|
11
11
|
}
|
|
12
|
-
if (process.env.TESTOMATIO_TOKEN) {
|
|
12
|
+
if (process.env.TESTOMATIO_TOKEN && !process.env.TESTOMATIO) {
|
|
13
13
|
process.env.TESTOMATIO = process.env.TESTOMATIO_TOKEN;
|
|
14
14
|
}
|
|
15
15
|
|
package/src/pipe/html.js
CHANGED
package/src/xmlReader.js
CHANGED
|
@@ -226,7 +226,7 @@ class XmlReader {
|
|
|
226
226
|
|
|
227
227
|
return {
|
|
228
228
|
status,
|
|
229
|
-
create_tests:
|
|
229
|
+
create_tests: true,
|
|
230
230
|
tests_count: parseInt(counters.total, 10),
|
|
231
231
|
passed_count: parseInt(counters.passed, 10),
|
|
232
232
|
skipped_count: parseInt(counters.notExecuted, 10),
|