@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/codecept.js
CHANGED
|
@@ -1,327 +1,369 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const picocolors_1 = __importDefault(require("picocolors"));
|
|
9
|
-
const client_js_1 = __importDefault(require("../client.js"));
|
|
10
|
-
const constants_js_1 = require("../constants.js");
|
|
11
|
-
const utils_js_1 = require("../utils/utils.js");
|
|
12
|
-
const index_js_1 = require("../services/index.js");
|
|
13
|
-
const codeceptjs_1 = __importDefault(require("codeceptjs"));
|
|
14
|
-
const debug = (0, debug_1.default)('@testomatio/reporter:adapter:codeceptjs');
|
|
15
|
-
// @ts-ignore
|
|
1
|
+
const debug = require('debug')('@testomatio/reporter:adapter:codeceptjs');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
const TestomatClient = require('../client');
|
|
4
|
+
const { STATUS, APP_PREFIX, TESTOMAT_TMP_STORAGE_DIR } = require('../constants');
|
|
5
|
+
const { getTestomatIdFromTestTitle, fileSystem } = require('../utils/utils');
|
|
6
|
+
const { services } = require('../services');
|
|
7
|
+
|
|
16
8
|
if (!global.codeceptjs) {
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
// eslint-disable-next-line global-require, import/no-extraneous-dependencies
|
|
10
|
+
global.codeceptjs = require('codeceptjs');
|
|
19
11
|
}
|
|
20
|
-
|
|
12
|
+
|
|
21
13
|
const { event, recorder, codecept } = global.codeceptjs;
|
|
14
|
+
|
|
22
15
|
let currentMetaStep = [];
|
|
23
16
|
let error;
|
|
24
17
|
let stepShift = 0;
|
|
18
|
+
|
|
25
19
|
// const output = new Output({
|
|
26
20
|
// filterFn: stack => !stack.includes('codeceptjs/lib/output'), // output from codeceptjs
|
|
27
21
|
// });
|
|
22
|
+
|
|
28
23
|
let stepStart = new Date();
|
|
24
|
+
|
|
29
25
|
const MAJOR_VERSION = parseInt(codecept.version().match(/\d/)[0], 10);
|
|
26
|
+
|
|
30
27
|
const DATA_REGEXP = /[|\s]+?(\{".*\}|\[.*\])/;
|
|
28
|
+
|
|
31
29
|
if (MAJOR_VERSION < 3) {
|
|
32
|
-
|
|
30
|
+
console.log('🔴 This reporter works with CodeceptJS 3+, please update your tests');
|
|
33
31
|
}
|
|
32
|
+
|
|
34
33
|
function CodeceptReporter(config) {
|
|
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
|
-
debug('waiting for all tests to be reported');
|
|
112
|
-
// all tests were reported and we can upload videos
|
|
113
|
-
await Promise.all(reportTestPromises);
|
|
114
|
-
await uploadAttachments(client, videos, '🎞️ Uploading', 'video');
|
|
115
|
-
await uploadAttachments(client, traces, '📁 Uploading', 'trace');
|
|
116
|
-
const status = failedTests.length === 0 ? constants_js_1.STATUS.PASSED : constants_js_1.STATUS.FAILED;
|
|
117
|
-
// @ts-ignore
|
|
118
|
-
client.updateRunStatus(status);
|
|
119
|
-
});
|
|
120
|
-
event.dispatcher.on(event.test.passed, test => {
|
|
121
|
-
const { uid, tags, title } = test;
|
|
122
|
-
if (uid && failedTests.includes(uid)) {
|
|
123
|
-
failedTests = failedTests.filter(failed => uid !== failed);
|
|
124
|
-
}
|
|
125
|
-
const testObj = getTestAndMessage(title);
|
|
126
|
-
const logs = getTestLogs(test);
|
|
127
|
-
const manuallyAttachedArtifacts = index_js_1.services.artifacts.get(test.fullTitle());
|
|
128
|
-
const keyValues = index_js_1.services.keyValues.get(test.fullTitle());
|
|
129
|
-
index_js_1.services.setContext(null);
|
|
130
|
-
client.addTestRun(constants_js_1.STATUS.PASSED, {
|
|
131
|
-
...stripExampleFromTitle(title),
|
|
132
|
-
rid: uid,
|
|
133
|
-
suite_title: test.parent && test.parent.title,
|
|
134
|
-
message: testObj.message,
|
|
135
|
-
time: getDuration(test),
|
|
136
|
-
steps: global.testomatioDataStore.steps.join('\n') || null,
|
|
137
|
-
test_id: (0, utils_js_1.getTestomatIdFromTestTitle)(`${title} ${tags?.join(' ')}`),
|
|
138
|
-
logs,
|
|
139
|
-
manuallyAttachedArtifacts,
|
|
140
|
-
meta: keyValues,
|
|
141
|
-
});
|
|
142
|
-
// output.stop();
|
|
143
|
-
});
|
|
144
|
-
event.dispatcher.on(event.test.failed, (test, err) => {
|
|
145
|
-
error = err;
|
|
146
|
-
});
|
|
147
|
-
event.dispatcher.on(event.hook.failed, (suite, err) => {
|
|
148
|
-
error = err;
|
|
149
|
-
if (!suite)
|
|
150
|
-
return;
|
|
151
|
-
if (!suite.tests)
|
|
152
|
-
return;
|
|
153
|
-
for (const test of suite.tests) {
|
|
154
|
-
const { uid, tags, title } = test;
|
|
155
|
-
failedTests.push(uid || title);
|
|
156
|
-
const testId = (0, utils_js_1.getTestomatIdFromTestTitle)(`${title} ${tags?.join(' ')}`);
|
|
157
|
-
client.addTestRun(constants_js_1.STATUS.FAILED, {
|
|
158
|
-
rid: uid,
|
|
159
|
-
...stripExampleFromTitle(title),
|
|
160
|
-
suite_title: suite.title,
|
|
161
|
-
test_id: testId,
|
|
162
|
-
error,
|
|
163
|
-
time: 0,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
// output.stop();
|
|
34
|
+
let failedTests = [];
|
|
35
|
+
let videos = [];
|
|
36
|
+
let traces = [];
|
|
37
|
+
const reportTestPromises = [];
|
|
38
|
+
|
|
39
|
+
const testTimeMap = {};
|
|
40
|
+
const { apiKey } = config;
|
|
41
|
+
|
|
42
|
+
const getDuration = test => {
|
|
43
|
+
if (!test.uid) return 0;
|
|
44
|
+
if (testTimeMap[test.uid]) {
|
|
45
|
+
return Date.now() - testTimeMap[test.uid];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return 0;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const client = new TestomatClient({ apiKey });
|
|
52
|
+
|
|
53
|
+
recorder.startUnlessRunning();
|
|
54
|
+
|
|
55
|
+
// Listening to events
|
|
56
|
+
event.dispatcher.on(event.all.before, () => {
|
|
57
|
+
// clear tmp dir
|
|
58
|
+
fileSystem.clearDir(TESTOMAT_TMP_STORAGE_DIR);
|
|
59
|
+
|
|
60
|
+
// recorder.add('Creating new run', () => );
|
|
61
|
+
client.createRun();
|
|
62
|
+
videos = [];
|
|
63
|
+
traces = [];
|
|
64
|
+
|
|
65
|
+
if (!global.testomatioDataStore) global.testomatioDataStore = {};
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
let hookSteps = [];
|
|
69
|
+
let suiteHookRunning = false;
|
|
70
|
+
|
|
71
|
+
event.dispatcher.on(event.suite.before, suite => {
|
|
72
|
+
suiteHookRunning = true;
|
|
73
|
+
hookSteps = [];
|
|
74
|
+
global.testomatioDataStore.steps = [];
|
|
75
|
+
|
|
76
|
+
services.setContext(suite.fullTitle());
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
event.dispatcher.on(event.suite.after, () => {
|
|
80
|
+
services.setContext(null);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
event.dispatcher.on(event.hook.started, () => {
|
|
84
|
+
// global.testomatioDataStore.steps = [];
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
event.dispatcher.on(event.hook.passed, () => {
|
|
88
|
+
if (suiteHookRunning) {
|
|
89
|
+
hookSteps.push(...global.testomatioDataStore.steps);
|
|
90
|
+
services.setContext(null);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
event.dispatcher.on(event.hook.failed, () => {
|
|
95
|
+
if (suiteHookRunning) {
|
|
96
|
+
hookSteps.push(...global.testomatioDataStore.steps);
|
|
97
|
+
services.setContext(null);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
event.dispatcher.on(event.test.before, test => {
|
|
102
|
+
suiteHookRunning = false;
|
|
103
|
+
global.testomatioDataStore.steps = [];
|
|
104
|
+
|
|
105
|
+
recorder.add(() => {
|
|
106
|
+
currentMetaStep = [];
|
|
107
|
+
// output.reset();
|
|
108
|
+
// output.start();
|
|
109
|
+
stepShift = 0;
|
|
167
110
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
111
|
+
|
|
112
|
+
if (!global.testomatioDataStore) global.testomatioDataStore = {};
|
|
113
|
+
// reset steps
|
|
114
|
+
global.testomatioDataStore.steps = [];
|
|
115
|
+
|
|
116
|
+
services.setContext(test.fullTitle());
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
event.dispatcher.on(event.test.started, test => {
|
|
120
|
+
services.setContext(test.fullTitle());
|
|
121
|
+
|
|
122
|
+
if (!test.uid) return;
|
|
123
|
+
|
|
124
|
+
testTimeMap[test.uid] = Date.now();
|
|
125
|
+
// start logging
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
event.dispatcher.on(event.all.result, async () => {
|
|
129
|
+
debug('waiting for all tests to be reported');
|
|
130
|
+
// all tests were reported and we can upload videos
|
|
131
|
+
await Promise.all(reportTestPromises);
|
|
132
|
+
|
|
133
|
+
await uploadAttachments(client, videos, '🎞️ Uploading', 'video');
|
|
134
|
+
await uploadAttachments(client, traces, '📁 Uploading', 'trace');
|
|
135
|
+
|
|
136
|
+
const status = failedTests.length === 0 ? STATUS.PASSED : STATUS.FAILED;
|
|
137
|
+
client.updateRunStatus(status);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
event.dispatcher.on(event.test.passed, test => {
|
|
141
|
+
const { uid, tags, title } = test;
|
|
142
|
+
if (uid && failedTests.includes(uid)) {
|
|
143
|
+
failedTests = failedTests.filter(failed => uid !== failed);
|
|
144
|
+
}
|
|
145
|
+
const testObj = getTestAndMessage(title);
|
|
146
|
+
|
|
147
|
+
const logs = getTestLogs(test);
|
|
148
|
+
const manuallyAttachedArtifacts = services.artifacts.get(test.fullTitle());
|
|
149
|
+
const keyValues = services.keyValues.get(test.fullTitle());
|
|
150
|
+
services.setContext(null);
|
|
151
|
+
|
|
152
|
+
client.addTestRun(STATUS.PASSED, {
|
|
153
|
+
...stripExampleFromTitle(title),
|
|
154
|
+
rid: uid,
|
|
155
|
+
suite_title: test.parent && test.parent.title,
|
|
156
|
+
message: testObj.message,
|
|
157
|
+
time: getDuration(test),
|
|
158
|
+
steps: global.testomatioDataStore.steps.join('\n') || null,
|
|
159
|
+
test_id: getTestomatIdFromTestTitle(`${title} ${tags?.join(' ')}`),
|
|
160
|
+
logs,
|
|
161
|
+
manuallyAttachedArtifacts,
|
|
162
|
+
meta: keyValues,
|
|
206
163
|
});
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
164
|
+
// output.stop();
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
event.dispatcher.on(event.test.failed, (test, err) => {
|
|
168
|
+
error = err;
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
event.dispatcher.on(event.hook.failed, (suite, err) => {
|
|
172
|
+
error = err;
|
|
173
|
+
|
|
174
|
+
if (!suite) return;
|
|
175
|
+
if (!suite.tests) return;
|
|
176
|
+
for (const test of suite.tests) {
|
|
177
|
+
const { uid, tags, title } = test;
|
|
178
|
+
failedTests.push(uid || title);
|
|
179
|
+
const testId = getTestomatIdFromTestTitle(`${title} ${tags?.join(' ')}`);
|
|
180
|
+
|
|
181
|
+
client.addTestRun(STATUS.FAILED, {
|
|
182
|
+
rid: uid,
|
|
183
|
+
...stripExampleFromTitle(title),
|
|
184
|
+
suite_title: suite.title,
|
|
185
|
+
test_id: testId,
|
|
186
|
+
error,
|
|
187
|
+
time: 0,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
// output.stop();
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
event.dispatcher.on(event.test.after, test => {
|
|
194
|
+
if (test.state && test.state !== STATUS.FAILED) return;
|
|
195
|
+
if (test.err) error = test.err;
|
|
196
|
+
const { uid, tags, title, artifacts } = test;
|
|
197
|
+
failedTests.push(uid || title);
|
|
198
|
+
const testObj = getTestAndMessage(title);
|
|
199
|
+
|
|
200
|
+
const files = [];
|
|
201
|
+
if (artifacts.screenshot) files.push({ path: artifacts.screenshot, type: 'image/png' });
|
|
202
|
+
// todo: video must be uploaded later....
|
|
203
|
+
|
|
204
|
+
const logs = getTestLogs(test);
|
|
205
|
+
const manuallyAttachedArtifacts = services.artifacts.get(test.fullTitle());
|
|
206
|
+
const keyValues = services.keyValues.get(test.fullTitle());
|
|
207
|
+
services.setContext(null);
|
|
208
|
+
|
|
209
|
+
client.addTestRun(STATUS.FAILED, {
|
|
210
|
+
...stripExampleFromTitle(title),
|
|
211
|
+
rid: uid,
|
|
212
|
+
test_id: getTestomatIdFromTestTitle(`${title} ${tags?.join(' ')}`),
|
|
213
|
+
suite_title: test.parent && test.parent.title,
|
|
214
|
+
error,
|
|
215
|
+
message: testObj.message,
|
|
216
|
+
time: getDuration(test),
|
|
217
|
+
files,
|
|
218
|
+
steps: global.testomatioDataStore?.steps?.join('\n') || null,
|
|
219
|
+
logs,
|
|
220
|
+
manuallyAttachedArtifacts,
|
|
221
|
+
meta: keyValues,
|
|
221
222
|
});
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
223
|
+
|
|
224
|
+
debug('artifacts', artifacts);
|
|
225
|
+
|
|
226
|
+
for (const aid in artifacts) {
|
|
227
|
+
if (aid.startsWith('video')) videos.push({ rid: uid, title, path: artifacts[aid], type: 'video/webm' });
|
|
228
|
+
if (aid.startsWith('trace')) traces.push({ rid: uid, title, path: artifacts[aid], type: 'application/zip' });
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// output.stop();
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
event.dispatcher.on(event.test.skipped, test => {
|
|
235
|
+
const { uid, tags, title } = test;
|
|
236
|
+
if (failedTests.includes(uid || title)) return;
|
|
237
|
+
|
|
238
|
+
const testObj = getTestAndMessage(title);
|
|
239
|
+
client.addTestRun(STATUS.SKIPPED, {
|
|
240
|
+
rid: uid,
|
|
241
|
+
...stripExampleFromTitle(title),
|
|
242
|
+
test_id: getTestomatIdFromTestTitle(`${title} ${tags?.join(' ')}`),
|
|
243
|
+
suite_title: test.parent && test.parent.title,
|
|
244
|
+
message: testObj.message,
|
|
245
|
+
time: getDuration(test),
|
|
226
246
|
});
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (step.status === constants_js_1.STATUS.FAILED) {
|
|
260
|
-
// output.push(repeat(stepShift) + pc.red(step.toString()) + duration);
|
|
261
|
-
global.testomatioDataStore?.steps?.push(repeat(stepShift) + picocolors_1.default.red(step.toString()) + duration);
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
// output.push(repeat(stepShift) + step.toString() + duration);
|
|
265
|
-
global.testomatioDataStore?.steps?.push(repeat(stepShift) + step.toString() + duration);
|
|
247
|
+
// output.stop();
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
event.dispatcher.on(event.step.started, step => {
|
|
251
|
+
stepShift = 0;
|
|
252
|
+
step.started = true;
|
|
253
|
+
stepStart = new Date();
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
event.dispatcher.on(event.step.finished, step => {
|
|
257
|
+
if (!step.started) return;
|
|
258
|
+
let processingStep = step;
|
|
259
|
+
const metaSteps = [];
|
|
260
|
+
while (processingStep.metaStep) {
|
|
261
|
+
metaSteps.unshift(processingStep.metaStep);
|
|
262
|
+
processingStep = processingStep.metaStep;
|
|
263
|
+
}
|
|
264
|
+
const shift = metaSteps.length;
|
|
265
|
+
|
|
266
|
+
for (let i = 0; i < Math.max(currentMetaStep.length, metaSteps.length); i++) {
|
|
267
|
+
if (currentMetaStep[i] !== metaSteps[i]) {
|
|
268
|
+
stepShift = 2 * i;
|
|
269
|
+
// eslint-disable-next-line no-continue
|
|
270
|
+
if (!metaSteps[i]) continue;
|
|
271
|
+
if (metaSteps[i].isBDD()) {
|
|
272
|
+
// output.push(repeat(stepShift) + chalk.bold(metaSteps[i].toString()) + metaSteps[i].comment);
|
|
273
|
+
global.testomatioDataStore?.steps?.push(
|
|
274
|
+
repeat(stepShift) + chalk.bold(metaSteps[i].toString()) + metaSteps[i].comment,
|
|
275
|
+
);
|
|
276
|
+
} else {
|
|
277
|
+
// output.push(repeat(stepShift) + chalk.green.bold(metaSteps[i].toString()));
|
|
278
|
+
global.testomatioDataStore?.steps?.push(repeat(stepShift) + chalk.green.bold(metaSteps[i].toString()));
|
|
266
279
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
currentMetaStep = metaSteps;
|
|
283
|
+
stepShift = 2 * shift;
|
|
284
|
+
|
|
285
|
+
const durationMs = +new Date() - +stepStart;
|
|
286
|
+
let duration = '';
|
|
287
|
+
if (durationMs) {
|
|
288
|
+
duration = repeat(1) + chalk.grey(`(${durationMs}ms)`);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
if (step.status === STATUS.FAILED) {
|
|
292
|
+
// output.push(repeat(stepShift) + chalk.red(step.toString()) + duration);
|
|
293
|
+
global.testomatioDataStore?.steps?.push(repeat(stepShift) + chalk.red(step.toString()) + duration);
|
|
294
|
+
} else {
|
|
295
|
+
// output.push(repeat(stepShift) + step.toString() + duration);
|
|
296
|
+
global.testomatioDataStore?.steps?.push(repeat(stepShift) + step.toString() + duration);
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
event.dispatcher.on(event.step.comment, step => {
|
|
301
|
+
// output.push(chalk.cyan.bold(step.toString()));
|
|
302
|
+
global.testomatioDataStore?.steps?.push(chalk.cyan.bold(step.toString()));
|
|
303
|
+
});
|
|
272
304
|
}
|
|
305
|
+
|
|
273
306
|
async function uploadAttachments(client, attachments, messagePrefix, attachmentType) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
307
|
+
if (!attachments?.length) return;
|
|
308
|
+
|
|
309
|
+
if (client.uploader.isEnabled) {
|
|
310
|
+
console.log(APP_PREFIX, `Attachments: ${messagePrefix} ${attachments.length} ${attachmentType} ...`);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const promises = attachments.map(async attachment => {
|
|
314
|
+
const { rid, title, path, type } = attachment;
|
|
315
|
+
const file = { path, type, title };
|
|
316
|
+
|
|
317
|
+
// we are storing file if upload is disabled
|
|
318
|
+
if (!client.uploader.isEnabled) return client.uploader.storeUploadedFile(path, client.runId, rid, false);
|
|
319
|
+
|
|
320
|
+
return client.addTestRun(undefined, {
|
|
321
|
+
...stripExampleFromTitle(title),
|
|
322
|
+
rid,
|
|
323
|
+
files: [file],
|
|
290
324
|
});
|
|
291
|
-
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
await Promise.all(promises);
|
|
292
328
|
}
|
|
329
|
+
|
|
293
330
|
function getTestAndMessage(title) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
331
|
+
const testObj = { message: '' };
|
|
332
|
+
const testArr = title.split(/\s(\|\s\{.*?\})/);
|
|
333
|
+
testObj.title = testArr[0];
|
|
334
|
+
|
|
335
|
+
return testObj;
|
|
298
336
|
}
|
|
337
|
+
|
|
299
338
|
function stripExampleFromTitle(title) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
339
|
+
const res = title.match(DATA_REGEXP);
|
|
340
|
+
if (!res) return { title, example: null };
|
|
341
|
+
|
|
342
|
+
const example = JSON.parse(res[1]);
|
|
343
|
+
title = title.replace(DATA_REGEXP, '').trim();
|
|
344
|
+
|
|
345
|
+
return { title, example };
|
|
306
346
|
}
|
|
347
|
+
|
|
307
348
|
function repeat(num) {
|
|
308
|
-
|
|
349
|
+
return ''.padStart(num, ' ');
|
|
309
350
|
}
|
|
351
|
+
|
|
310
352
|
// TODO: think about moving to some common utils
|
|
311
353
|
function getTestLogs(test) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
|
|
354
|
+
const suiteLogsArr = services.logger.getLogs(test.parent.fullTitle());
|
|
355
|
+
const suiteLogs = suiteLogsArr ? suiteLogsArr.join('\n').trim() : '';
|
|
356
|
+
const testLogsArr = services.logger.getLogs(test.fullTitle());
|
|
357
|
+
const testLogs = testLogsArr ? testLogsArr.join('\n').trim() : '';
|
|
358
|
+
|
|
359
|
+
let logs = '';
|
|
360
|
+
if (suiteLogs) {
|
|
361
|
+
logs += `${chalk.bold('\t--- BeforeSuite ---')}\n${suiteLogs}`;
|
|
362
|
+
}
|
|
363
|
+
if (testLogs) {
|
|
364
|
+
logs += `\n${chalk.bold('\t--- Test ---')}\n${testLogs}`;
|
|
365
|
+
}
|
|
366
|
+
return logs;
|
|
324
367
|
}
|
|
325
|
-
module.exports = CodeceptReporter;
|
|
326
368
|
|
|
327
|
-
module.exports
|
|
369
|
+
module.exports = CodeceptReporter;
|