@testomatio/reporter 1.6.0-beta-2-artifacts → 2.0.0-beta-esm
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 +288 -330
- package/lib/adapter/cucumber/current.js +195 -203
- package/lib/adapter/cucumber/legacy.js +130 -155
- package/lib/adapter/cucumber.js +5 -16
- package/lib/adapter/cypress-plugin/index.js +91 -105
- package/lib/adapter/jasmine/jasmine.js +63 -0
- package/lib/adapter/jasmine.js +54 -53
- package/lib/adapter/jest.js +97 -99
- package/lib/adapter/mocha/mocha.js +125 -0
- package/lib/adapter/mocha.js +111 -140
- package/lib/adapter/playwright.js +168 -200
- package/lib/adapter/vitest.js +144 -143
- package/lib/adapter/webdriver.js +113 -97
- package/lib/bin/reportXml.js +49 -49
- package/lib/bin/startTest.js +80 -97
- package/lib/client.js +344 -385
- package/lib/config.js +16 -21
- package/lib/constants.js +49 -43
- package/lib/data-storage.js +206 -188
- package/lib/fileUploader.js +245 -0
- package/lib/junit-adapter/adapter.js +17 -20
- package/lib/junit-adapter/csharp.js +18 -14
- package/lib/junit-adapter/index.js +27 -25
- package/lib/junit-adapter/java.js +41 -53
- package/lib/junit-adapter/javascript.js +30 -27
- package/lib/junit-adapter/python.js +38 -37
- package/lib/junit-adapter/ruby.js +11 -8
- package/lib/output.js +44 -52
- package/lib/package.json +1 -0
- package/lib/pipe/bitbucket.js +208 -227
- package/lib/pipe/csv.js +111 -124
- package/lib/pipe/github.js +184 -211
- package/lib/pipe/gitlab.js +164 -205
- package/lib/pipe/html.js +253 -312
- package/lib/pipe/index.js +83 -63
- package/lib/pipe/testomatio.js +391 -454
- package/lib/reporter-functions.js +16 -20
- package/lib/reporter.js +47 -17
- package/lib/services/artifacts.js +55 -51
- package/lib/services/index.js +14 -12
- package/lib/services/key-values.js +56 -53
- package/lib/services/logger.js +227 -245
- package/lib/utils/chalk.js +10 -0
- package/lib/utils/pipe_utils.js +91 -84
- package/lib/utils/utils.js +289 -273
- package/lib/xmlReader.js +480 -519
- package/package.json +57 -19
- package/src/adapter/codecept.js +369 -0
- package/src/adapter/cucumber/current.js +228 -0
- package/src/adapter/cucumber/legacy.js +158 -0
- package/src/adapter/cucumber.js +4 -0
- package/src/adapter/cypress-plugin/index.js +110 -0
- package/src/adapter/jasmine.js +60 -0
- package/src/adapter/jest.js +107 -0
- package/src/adapter/mocha.cjs +2 -0
- package/src/adapter/mocha.js +156 -0
- package/src/adapter/playwright.js +222 -0
- package/src/adapter/vitest.js +183 -0
- package/src/adapter/webdriver.js +111 -0
- package/src/bin/reportXml.js +67 -0
- package/src/bin/startTest.js +119 -0
- package/src/client.js +423 -0
- package/src/config.js +30 -0
- package/src/constants.js +49 -0
- package/src/data-storage.js +204 -0
- package/src/fileUploader.js +307 -0
- package/src/junit-adapter/adapter.js +23 -0
- package/src/junit-adapter/csharp.js +16 -0
- package/src/junit-adapter/index.js +28 -0
- package/src/junit-adapter/java.js +58 -0
- package/src/junit-adapter/javascript.js +31 -0
- package/src/junit-adapter/python.js +42 -0
- package/src/junit-adapter/ruby.js +10 -0
- package/src/output.js +57 -0
- package/src/pipe/bitbucket.js +254 -0
- package/src/pipe/csv.js +140 -0
- package/src/pipe/github.js +234 -0
- package/src/pipe/gitlab.js +229 -0
- package/src/pipe/html.js +366 -0
- package/src/pipe/index.js +73 -0
- package/src/pipe/testomatio.js +498 -0
- package/src/reporter-functions.js +44 -0
- package/src/reporter.cjs +22 -0
- package/src/reporter.js +24 -0
- package/src/services/artifacts.js +59 -0
- package/src/services/index.js +13 -0
- package/src/services/key-values.js +59 -0
- package/src/services/logger.js +314 -0
- package/src/template/emptyData.svg +23 -0
- package/src/template/testomatio.hbs +1421 -0
- package/src/utils/chalk.js +13 -0
- package/src/utils/pipe_utils.js +127 -0
- package/src/utils/utils.js +341 -0
- package/src/xmlReader.js +551 -0
- package/lib/bin/cli.js +0 -216
- package/lib/bin/uploadArtifacts.js +0 -86
- package/lib/uploader.js +0 -312
|
@@ -1,155 +1,130 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
// if (event.result.status === 'undefined') {
|
|
133
|
-
// cliMessage += chalk.yellow(
|
|
134
|
-
// ' (undefined steps. Run Cucumber without this formatter and implement missing steps)',
|
|
135
|
-
// );
|
|
136
|
-
// message = 'Undefined steps. Implement missing steps and rerun this scenario';
|
|
137
|
-
// }
|
|
138
|
-
console.log(cliMessage);
|
|
139
|
-
if (status !== STATUS.PASSED && status !== STATUS.SKIPPED) {
|
|
140
|
-
this.status = STATUS.FAILED;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
this.client?.addTestRun(status, {
|
|
144
|
-
error: event.result.exception instanceof Error ? event.result.exception : undefined,
|
|
145
|
-
message,
|
|
146
|
-
example,
|
|
147
|
-
test_id: testId,
|
|
148
|
-
title: getTitle(scenario),
|
|
149
|
-
suite_title: getTitle(getFeature(event.sourceLocation.uri)),
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
module.exports = createTestomatFormatter(config.TESTOMATIO);
|
|
1
|
+
// import { Formatter } from 'cucumber';
|
|
2
|
+
// import pc from 'picocolors';
|
|
3
|
+
// import { getTestomatIdFromTestTitle, fileSystem } from '../../utils/utils.js';
|
|
4
|
+
// import { STATUS, TESTOMAT_TMP_STORAGE_DIR } from '../../constants.js';
|
|
5
|
+
// import TestomatClient from '../../client.js';
|
|
6
|
+
// import {config} from '../../config.js';
|
|
7
|
+
// const createTestomatFormatter = apiKey => {
|
|
8
|
+
// if (!apiKey || apiKey === '') {
|
|
9
|
+
// console.log(pc.red('TESTOMATIO key is empty, ignoring reports'));
|
|
10
|
+
// }
|
|
11
|
+
// const documents = {};
|
|
12
|
+
// const dataTableMap = {};
|
|
13
|
+
// const addDocument = gherkinDocument => {
|
|
14
|
+
// documents[gherkinDocument.uri] = gherkinDocument.document;
|
|
15
|
+
// };
|
|
16
|
+
// const getTitle = scenario => {
|
|
17
|
+
// let { name } = scenario;
|
|
18
|
+
// if (scenario.tags.length) {
|
|
19
|
+
// let tags = '';
|
|
20
|
+
// for (const tag of scenario.tags) {
|
|
21
|
+
// tags = `${tags} ${tag.name}`;
|
|
22
|
+
// }
|
|
23
|
+
// name = `${name}${tags}`;
|
|
24
|
+
// }
|
|
25
|
+
// return name;
|
|
26
|
+
// };
|
|
27
|
+
// const getFeature = uri => documents[uri].feature;
|
|
28
|
+
// const getScenario = location => {
|
|
29
|
+
// const { children } = getFeature(location.uri);
|
|
30
|
+
// for (const scenario of children) {
|
|
31
|
+
// if (scenario.type === 'Scenario' && scenario.location.line === location.line) {
|
|
32
|
+
// return scenario;
|
|
33
|
+
// }
|
|
34
|
+
// if (scenario.type === 'ScenarioOutline') {
|
|
35
|
+
// for (const example of scenario.examples) {
|
|
36
|
+
// for (const tableBody of example.tableBody) {
|
|
37
|
+
// if (tableBody.location.line === location.line) {
|
|
38
|
+
// return scenario;
|
|
39
|
+
// }
|
|
40
|
+
// }
|
|
41
|
+
// }
|
|
42
|
+
// }
|
|
43
|
+
// }
|
|
44
|
+
// return null;
|
|
45
|
+
// };
|
|
46
|
+
// const loadDataTable = (scenario, uri) => {
|
|
47
|
+
// if (scenario.type === 'ScenarioOutline') {
|
|
48
|
+
// for (const example of scenario.examples) {
|
|
49
|
+
// for (const tableBody of example.tableBody) {
|
|
50
|
+
// const dataMap = example.tableHeader.cells.reduce((acc, cell, index) => {
|
|
51
|
+
// acc[cell.value] = tableBody.cells[index].value;
|
|
52
|
+
// return acc;
|
|
53
|
+
// }, {});
|
|
54
|
+
// dataTableMap[`${uri}:${tableBody.location.line}`] = JSON.stringify(dataMap);
|
|
55
|
+
// }
|
|
56
|
+
// }
|
|
57
|
+
// }
|
|
58
|
+
// };
|
|
59
|
+
// const getDataTableMap = (scenario, sourceLocation) => {
|
|
60
|
+
// const key = `${sourceLocation.uri}:${sourceLocation.line}`;
|
|
61
|
+
// if (!dataTableMap[key]) {
|
|
62
|
+
// loadDataTable(scenario, sourceLocation.uri);
|
|
63
|
+
// }
|
|
64
|
+
// return dataTableMap[key] || '';
|
|
65
|
+
// };
|
|
66
|
+
// const getTestId = scenario => {
|
|
67
|
+
// if (scenario) {
|
|
68
|
+
// for (const tag of scenario.tags) {
|
|
69
|
+
// const testId = getTestomatIdFromTestTitle(tag.name);
|
|
70
|
+
// if (testId) return testId;
|
|
71
|
+
// }
|
|
72
|
+
// }
|
|
73
|
+
// return null;
|
|
74
|
+
// };
|
|
75
|
+
// return class TestomatFormatter extends Formatter {
|
|
76
|
+
// constructor(options) {
|
|
77
|
+
// super(options);
|
|
78
|
+
// if (!apiKey) return;
|
|
79
|
+
// this.client = new TestomatClient({ apiKey });
|
|
80
|
+
// this.status = STATUS.PASSED.toString();
|
|
81
|
+
// options.eventBroadcaster.on('gherkin-document', addDocument);
|
|
82
|
+
// options.eventBroadcaster.on('test-run-started', () => {
|
|
83
|
+
// fileSystem.clearDir(TESTOMAT_TMP_STORAGE_DIR);
|
|
84
|
+
// this?.client?.createRun();
|
|
85
|
+
// });
|
|
86
|
+
// options.eventBroadcaster.on('test-case-finished', this.onTestCaseFinished.bind(this));
|
|
87
|
+
// options.eventBroadcaster.on('test-case-started', this.onTestCaseStarted.bind(this));
|
|
88
|
+
// // @ts-ignore
|
|
89
|
+
// options.eventBroadcaster.on('test-run-finished', () => this?.client?.updateRunStatus(this.status));
|
|
90
|
+
// global.testomatioRunningEnvironment = 'cucumber:legacy';
|
|
91
|
+
// }
|
|
92
|
+
// onTestCaseStarted(event) {
|
|
93
|
+
// const scenario = getScenario(event.sourceLocation);
|
|
94
|
+
// const testId = getTestId(scenario);
|
|
95
|
+
// if (!global.testomatioDataStore) global.testomatioDataStore = {};
|
|
96
|
+
// global.testomatioDataStore.currentlyRunningTestId = testId;
|
|
97
|
+
// }
|
|
98
|
+
// onTestCaseFinished(event) {
|
|
99
|
+
// const scenario = getScenario(event.sourceLocation);
|
|
100
|
+
// const testId = getTestId(scenario);
|
|
101
|
+
// const status = event.result.status === 'undefined' ? STATUS.SKIPPED : event.result.status;
|
|
102
|
+
// let example = getDataTableMap(scenario, event.sourceLocation);
|
|
103
|
+
// if (example) example = JSON.parse(example);
|
|
104
|
+
// if (!scenario.name) return;
|
|
105
|
+
// const message = '';
|
|
106
|
+
// const cliMessage = `- ${scenario.name}: ${pc.bold(status.toUpperCase())}`;
|
|
107
|
+
// // if (event.result.status === 'undefined') {
|
|
108
|
+
// // cliMessage += pc.yellow(
|
|
109
|
+
// // ' (undefined steps. Run Cucumber without this formatter and implement missing steps)',
|
|
110
|
+
// // );
|
|
111
|
+
// // message = 'Undefined steps. Implement missing steps and rerun this scenario';
|
|
112
|
+
// // }
|
|
113
|
+
// console.log(cliMessage);
|
|
114
|
+
// if (status !== STATUS.PASSED && status !== STATUS.SKIPPED) {
|
|
115
|
+
// this.status = STATUS.FAILED;
|
|
116
|
+
// }
|
|
117
|
+
// this.client?.addTestRun(status, {
|
|
118
|
+
// error: event.result.exception instanceof Error ? event.result.exception : undefined,
|
|
119
|
+
// message,
|
|
120
|
+
// example,
|
|
121
|
+
// test_id: testId,
|
|
122
|
+
// title: getTitle(scenario),
|
|
123
|
+
// suite_title: getTitle(getFeature(event.sourceLocation.uri)),
|
|
124
|
+
// });
|
|
125
|
+
// }
|
|
126
|
+
// };
|
|
127
|
+
// };
|
|
128
|
+
// const CucumberLegacyReporter = createTestomatFormatter(config.TESTOMATIO);
|
|
129
|
+
// export { CucumberLegacyReporter };
|
|
130
|
+
// export default CucumberLegacyReporter;
|
package/lib/adapter/cucumber.js
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} catch (_e) {
|
|
7
|
-
try {
|
|
8
|
-
// eslint-disable-next-line global-require, import/no-extraneous-dependencies
|
|
9
|
-
require.resolve('cucumber');
|
|
10
|
-
// eslint-disable-next-line global-require, import/no-extraneous-dependencies
|
|
11
|
-
module.exports = require('./cucumber/legacy');
|
|
12
|
-
} catch (_err) {
|
|
13
|
-
console.error('Cucumber packages: "@cucumber/cucumber" or "cucumber" were not detected. Report won\'t be sent');
|
|
14
|
-
module.exports = {};
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const current_js_1 = require("./cucumber/current.js");
|
|
4
|
+
// import { CucumberLegacyReporter } from './cucumber/legacy.js';
|
|
5
|
+
module.exports = current_js_1.CucumberReporter;
|
|
@@ -1,109 +1,95 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 constants_js_1 = require("../../constants.js");
|
|
7
|
+
const utils_js_1 = require("../../utils/utils.js");
|
|
8
|
+
const client_js_1 = __importDefault(require("../../client.js"));
|
|
9
|
+
const config_js_1 = require("../../config.js");
|
|
6
10
|
const testomatioReporter = on => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
const client = new TestomatClient({ apiKey: config.TESTOMATIO });
|
|
12
|
-
|
|
13
|
-
on('before:run', async run => {
|
|
14
|
-
// TODO: looks like client.env does not exist
|
|
15
|
-
if (!client.env) {
|
|
16
|
-
client.env = `${run.browser.displayName},${run.system.osName}`;
|
|
17
|
-
}
|
|
18
|
-
await client.createRun();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
on('after:spec', async (_spec, results) => {
|
|
22
|
-
const addSpecTestsPromises = [];
|
|
23
|
-
|
|
24
|
-
const videos = [results.video];
|
|
25
|
-
|
|
26
|
-
for (const test of results.tests) {
|
|
27
|
-
const lastAttemptIndex = test.attempts.length - 1;
|
|
28
|
-
const latestAttempt = test.attempts[lastAttemptIndex];
|
|
29
|
-
|
|
30
|
-
// latestAttempt.duration && latestAttempt.error were available in adapters version up to 13 JFYI
|
|
31
|
-
const time = latestAttempt.duration || latestAttempt.wallClockDuration || test.duration;
|
|
32
|
-
let error = latestAttempt.error;
|
|
33
|
-
|
|
34
|
-
let title = test.title.pop();
|
|
35
|
-
const examples = title.match(/\(example (#\d+)\)/);
|
|
36
|
-
let example = null;
|
|
37
|
-
if (examples && examples[1]) example = { example: examples[1] };
|
|
38
|
-
title = title.replace(/\(example #\d+\)/, '').trim();
|
|
39
|
-
|
|
40
|
-
const suiteTitle = test.title.pop();
|
|
41
|
-
|
|
42
|
-
const testId = getTestomatIdFromTestTitle(title);
|
|
43
|
-
const suiteId = parseSuite(suiteTitle);
|
|
44
|
-
|
|
45
|
-
if (!error && test.displayError) {
|
|
46
|
-
error = { message: test.displayError };
|
|
47
|
-
error.inspect = function () {
|
|
48
|
-
// eslint-disable-line func-names
|
|
49
|
-
return this.message;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const formattedError = error
|
|
54
|
-
? {
|
|
55
|
-
message: error.message,
|
|
56
|
-
inspect:
|
|
57
|
-
error.inspect ||
|
|
58
|
-
function () {
|
|
59
|
-
return this.message;
|
|
60
|
-
},
|
|
61
|
-
}
|
|
62
|
-
: '';
|
|
63
|
-
|
|
64
|
-
const screenshots = Array.isArray(results.screenshots)
|
|
65
|
-
? results.screenshots
|
|
66
|
-
.filter(screenshot => screenshot?.path && screenshot?.path.includes(title) && screenshot?.takenAt)
|
|
67
|
-
.map(screenshot => screenshot.path)
|
|
68
|
-
: [];
|
|
69
|
-
|
|
70
|
-
const files = [...videos, ...screenshots];
|
|
71
|
-
|
|
72
|
-
let state;
|
|
73
|
-
switch (test.state) {
|
|
74
|
-
case 'passed':
|
|
75
|
-
state = STATUS.PASSED;
|
|
76
|
-
break;
|
|
77
|
-
case 'failed':
|
|
78
|
-
state = STATUS.FAILED;
|
|
79
|
-
break;
|
|
80
|
-
case 'skipped':
|
|
81
|
-
case 'pending':
|
|
82
|
-
default:
|
|
83
|
-
state = STATUS.SKIPPED;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
addSpecTestsPromises.push(
|
|
87
|
-
client.addTestRun(state, {
|
|
88
|
-
title,
|
|
89
|
-
time,
|
|
90
|
-
example,
|
|
91
|
-
error: formattedError,
|
|
92
|
-
files,
|
|
93
|
-
suite_title: suiteTitle,
|
|
94
|
-
test_id: testId,
|
|
95
|
-
suite_id: suiteId,
|
|
96
|
-
}),
|
|
97
|
-
);
|
|
11
|
+
if (!config_js_1.config.TESTOMATIO) {
|
|
12
|
+
console.log('TESTOMATIO key is empty, ignoring reports');
|
|
13
|
+
return;
|
|
98
14
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
15
|
+
const client = new client_js_1.default({ apiKey: config_js_1.config.TESTOMATIO });
|
|
16
|
+
on('before:run', async () => {
|
|
17
|
+
// TODO: looks like client.env does not exist
|
|
18
|
+
// if (!client.env) {
|
|
19
|
+
// client.env = `${run.browser.displayName},${run.system.osName}`;
|
|
20
|
+
// }
|
|
21
|
+
await client.createRun();
|
|
22
|
+
});
|
|
23
|
+
on('after:spec', async (_spec, results) => {
|
|
24
|
+
const addSpecTestsPromises = [];
|
|
25
|
+
const videos = [results.video];
|
|
26
|
+
for (const test of results.tests) {
|
|
27
|
+
const lastAttemptIndex = test.attempts.length - 1;
|
|
28
|
+
const latestAttempt = test.attempts[lastAttemptIndex];
|
|
29
|
+
// latestAttempt.duration && latestAttempt.error were available in adapters version up to 13 JFYI
|
|
30
|
+
const time = latestAttempt.duration || latestAttempt.wallClockDuration || test.duration;
|
|
31
|
+
let error = latestAttempt.error;
|
|
32
|
+
let title = test.title.pop();
|
|
33
|
+
const examples = title.match(/\(example (#\d+)\)/);
|
|
34
|
+
let example = null;
|
|
35
|
+
if (examples && examples[1])
|
|
36
|
+
example = { example: examples[1] };
|
|
37
|
+
title = title.replace(/\(example #\d+\)/, '').trim();
|
|
38
|
+
const suiteTitle = test.title.pop();
|
|
39
|
+
const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(title);
|
|
40
|
+
const suiteId = (0, utils_js_1.parseSuite)(suiteTitle);
|
|
41
|
+
if (!error && test.displayError) {
|
|
42
|
+
error = { message: test.displayError };
|
|
43
|
+
// eslint-disable-next-line
|
|
44
|
+
error.inspect = function () {
|
|
45
|
+
return this.message;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const formattedError = error ? {
|
|
49
|
+
message: error.message,
|
|
50
|
+
name: error.name,
|
|
51
|
+
inspect: error.inspect ||
|
|
52
|
+
// eslint-disable-next-line
|
|
53
|
+
function () {
|
|
54
|
+
return this.message;
|
|
55
|
+
},
|
|
56
|
+
} : undefined;
|
|
57
|
+
const screenshots = Array.isArray(results.screenshots)
|
|
58
|
+
? results.screenshots
|
|
59
|
+
.filter(screenshot => screenshot?.path && screenshot?.path.includes(title) && screenshot?.takenAt)
|
|
60
|
+
.map(screenshot => screenshot.path)
|
|
61
|
+
: [];
|
|
62
|
+
const files = [...videos, ...screenshots];
|
|
63
|
+
let state;
|
|
64
|
+
switch (test.state) {
|
|
65
|
+
case 'passed':
|
|
66
|
+
state = constants_js_1.STATUS.PASSED;
|
|
67
|
+
break;
|
|
68
|
+
case 'failed':
|
|
69
|
+
state = constants_js_1.STATUS.FAILED;
|
|
70
|
+
break;
|
|
71
|
+
case 'skipped':
|
|
72
|
+
case 'pending':
|
|
73
|
+
default:
|
|
74
|
+
state = constants_js_1.STATUS.SKIPPED;
|
|
75
|
+
}
|
|
76
|
+
addSpecTestsPromises.push(client.addTestRun(state, {
|
|
77
|
+
title,
|
|
78
|
+
time,
|
|
79
|
+
example,
|
|
80
|
+
error: formattedError,
|
|
81
|
+
files,
|
|
82
|
+
suite_title: suiteTitle,
|
|
83
|
+
test_id: testId,
|
|
84
|
+
suite_id: suiteId,
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
await Promise.all(addSpecTestsPromises);
|
|
88
|
+
});
|
|
89
|
+
on('after:run', async (results) => {
|
|
90
|
+
const status = results.totalFailed ? constants_js_1.STATUS.FAILED : constants_js_1.STATUS.PASSED;
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
await client.updateRunStatus(status);
|
|
93
|
+
});
|
|
107
94
|
};
|
|
108
|
-
|
|
109
95
|
module.exports = testomatioReporter;
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
exports.JasmineReporter = void 0;
|
|
7
|
+
const client_js_1 = __importDefault(require("../../client.js"));
|
|
8
|
+
const utils_js_1 = require("../../utils/utils.js");
|
|
9
|
+
const constants_js_1 = require("../../constants.js");
|
|
10
|
+
class JasmineReporter {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.testTimeMap = {};
|
|
13
|
+
this.client = new client_js_1.default({ apiKey: options?.apiKey });
|
|
14
|
+
this.client.createRun();
|
|
15
|
+
}
|
|
16
|
+
getDuration(test) {
|
|
17
|
+
if (this.testTimeMap[test.id]) {
|
|
18
|
+
return Date.now() - this.testTimeMap[test.id];
|
|
19
|
+
}
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
specStarted(result) {
|
|
23
|
+
this.testTimeMap[result.id] = Date.now();
|
|
24
|
+
}
|
|
25
|
+
specDone(result) {
|
|
26
|
+
if (!this.client)
|
|
27
|
+
return;
|
|
28
|
+
const title = result.description;
|
|
29
|
+
const { status } = result;
|
|
30
|
+
let errorMessage = '';
|
|
31
|
+
for (let i = 0; i < result.failedExpectations.length; i += 1) {
|
|
32
|
+
errorMessage = `${errorMessage}Failure: ${result.failedExpectations[i].message}\n`;
|
|
33
|
+
errorMessage = `${errorMessage}\n ${result.failedExpectations[i].stack}`;
|
|
34
|
+
}
|
|
35
|
+
console.log(`${title} : ${constants_js_1.STATUS.PASSED}`);
|
|
36
|
+
console.log(errorMessage);
|
|
37
|
+
const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(title);
|
|
38
|
+
errorMessage = errorMessage.replace((0, utils_js_1.ansiRegExp)(), '');
|
|
39
|
+
this.client.addTestRun(status, {
|
|
40
|
+
error: result.failedExpectations[0],
|
|
41
|
+
message: errorMessage,
|
|
42
|
+
test_id: testId,
|
|
43
|
+
title,
|
|
44
|
+
time: this.getDuration(result),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
jasmineDone(suiteInfo, done) {
|
|
48
|
+
if (!this.client)
|
|
49
|
+
return;
|
|
50
|
+
const { overallStatus } = suiteInfo;
|
|
51
|
+
const status = overallStatus === 'failed' ? constants_js_1.STATUS.FAILED : constants_js_1.STATUS.PASSED;
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
this.client.updateRunStatus(status).then(() => done);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.JasmineReporter = JasmineReporter;
|
|
57
|
+
module.exports = JasmineReporter;
|
|
58
|
+
|
|
59
|
+
module.exports.JasmineReporter = JasmineReporter;
|
|
60
|
+
|
|
61
|
+
module.exports.JasmineReporter = JasmineReporter;
|
|
62
|
+
|
|
63
|
+
module.exports.exports = exports;
|