@testomatio/reporter 2.1.0-beta-nightwatch → 2.1.0-beta.2-codeceptjs
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/README.md +1 -0
- package/lib/adapter/codecept.js +288 -202
- package/lib/adapter/cypress-plugin/index.js +0 -2
- package/lib/adapter/mocha.js +0 -1
- package/lib/adapter/nightwatch.js +5 -5
- package/lib/adapter/playwright.js +11 -3
- package/lib/adapter/webdriver.d.ts +1 -1
- package/lib/adapter/webdriver.js +18 -8
- package/lib/bin/cli.js +73 -8
- package/lib/bin/reportXml.js +4 -2
- package/lib/bin/startTest.js +3 -2
- package/lib/bin/uploadArtifacts.js +5 -4
- package/lib/client.js +31 -10
- package/lib/data-storage.d.ts +5 -5
- package/lib/data-storage.js +23 -13
- package/lib/junit-adapter/csharp.d.ts +1 -0
- package/lib/junit-adapter/csharp.js +11 -1
- package/lib/pipe/bitbucket.d.ts +2 -0
- package/lib/pipe/bitbucket.js +38 -26
- package/lib/pipe/debug.js +27 -6
- package/lib/pipe/github.d.ts +2 -2
- package/lib/pipe/github.js +35 -3
- package/lib/pipe/gitlab.d.ts +2 -0
- package/lib/pipe/gitlab.js +27 -9
- package/lib/pipe/html.js +0 -3
- package/lib/pipe/index.js +17 -7
- package/lib/pipe/testomatio.d.ts +3 -2
- package/lib/pipe/testomatio.js +85 -75
- package/lib/replay.d.ts +31 -0
- package/lib/replay.js +259 -0
- package/lib/reporter-functions.d.ts +7 -0
- package/lib/reporter-functions.js +36 -0
- package/lib/reporter.d.ts +15 -12
- package/lib/reporter.js +4 -1
- package/lib/services/artifacts.d.ts +1 -1
- package/lib/services/index.d.ts +2 -0
- package/lib/services/index.js +2 -0
- package/lib/services/key-values.d.ts +1 -1
- package/lib/services/labels.d.ts +22 -0
- package/lib/services/labels.js +62 -0
- package/lib/services/logger.d.ts +1 -1
- package/lib/services/logger.js +1 -2
- package/lib/template/testomatio.hbs +443 -68
- package/lib/uploader.js +10 -6
- package/lib/utils/constants.d.ts +12 -0
- package/lib/utils/constants.js +15 -0
- package/lib/utils/utils.d.ts +10 -1
- package/lib/utils/utils.js +70 -22
- package/lib/xmlReader.js +57 -19
- package/package.json +16 -11
- package/src/adapter/codecept.js +320 -214
- package/src/adapter/cypress-plugin/index.js +0 -2
- package/src/adapter/mocha.js +0 -1
- package/src/adapter/nightwatch.js +1 -1
- package/src/adapter/playwright.js +10 -7
- package/src/adapter/webdriver.js +13 -5
- package/src/bin/cli.js +78 -7
- package/src/bin/reportXml.js +4 -1
- package/src/bin/startTest.js +2 -1
- package/src/bin/uploadArtifacts.js +2 -1
- package/src/client.js +28 -5
- package/src/data-storage.js +6 -6
- package/src/junit-adapter/csharp.js +13 -1
- package/src/pipe/bitbucket.js +22 -24
- package/src/pipe/debug.js +26 -5
- package/src/pipe/github.js +1 -2
- package/src/pipe/gitlab.js +27 -9
- package/src/pipe/html.js +1 -4
- package/src/pipe/testomatio.js +112 -107
- package/src/replay.js +268 -0
- package/src/reporter-functions.js +41 -0
- package/src/reporter.js +3 -0
- package/src/services/index.js +2 -0
- package/src/services/labels.js +59 -0
- package/src/services/logger.js +1 -2
- package/src/template/testomatio.hbs +443 -68
- package/src/uploader.js +11 -6
- package/src/utils/constants.js +12 -0
- package/src/utils/utils.js +67 -15
- package/src/xmlReader.js +73 -18
package/src/pipe/gitlab.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import createDebugMessages from 'debug';
|
|
2
|
-
import
|
|
2
|
+
import { Gaxios } from 'gaxios';
|
|
3
3
|
import pc from 'picocolors';
|
|
4
4
|
import humanizeDuration from 'humanize-duration';
|
|
5
5
|
import merge from 'lodash.merge';
|
|
@@ -45,6 +45,12 @@ class GitLabPipe {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
this.isEnabled = true;
|
|
48
|
+
this.client = new Gaxios({
|
|
49
|
+
baseURL: 'https://gitlab.com/api/v4',
|
|
50
|
+
headers: {
|
|
51
|
+
'Content-Type': 'application/json',
|
|
52
|
+
}
|
|
53
|
+
});
|
|
48
54
|
|
|
49
55
|
debug('GitLab Pipe: Enabled');
|
|
50
56
|
}
|
|
@@ -149,7 +155,6 @@ class GitLabPipe {
|
|
|
149
155
|
if (this.tests.length > 0) {
|
|
150
156
|
body += '\n<details>\n<summary><h3>🐢 Slowest Tests</h3></summary>\n\n';
|
|
151
157
|
body += this.tests
|
|
152
|
-
// eslint-disable-next-line no-unsafe-optional-chaining
|
|
153
158
|
.sort((a, b) => b?.run_time - a?.run_time)
|
|
154
159
|
.slice(0, 5)
|
|
155
160
|
.map(t => `* ${fullName(t)} (${humanizeDuration(parseFloat(t.run_time))})`)
|
|
@@ -158,16 +163,21 @@ class GitLabPipe {
|
|
|
158
163
|
}
|
|
159
164
|
|
|
160
165
|
// eslint-disable-next-line max-len
|
|
161
|
-
const commentsRequestURL =
|
|
166
|
+
const commentsRequestURL = `/projects/${this.ENV.CI_PROJECT_ID}/merge_requests/${this.ENV.CI_MERGE_REQUEST_IID}/notes`;
|
|
162
167
|
|
|
163
168
|
// delete previous report
|
|
164
|
-
await deletePreviousReport(
|
|
169
|
+
await deletePreviousReport(this.client, commentsRequestURL, this.hiddenCommentData, this.token);
|
|
165
170
|
|
|
166
171
|
// add current report
|
|
167
172
|
debug(`Adding comment via url: ${commentsRequestURL}`);
|
|
168
173
|
|
|
169
174
|
try {
|
|
170
|
-
const addCommentResponse = await
|
|
175
|
+
const addCommentResponse = await this.client.request({
|
|
176
|
+
method: 'POST',
|
|
177
|
+
url: commentsRequestURL,
|
|
178
|
+
params: { access_token: this.token },
|
|
179
|
+
data: { body }
|
|
180
|
+
});
|
|
171
181
|
|
|
172
182
|
const commentID = addCommentResponse.data.id;
|
|
173
183
|
// eslint-disable-next-line max-len
|
|
@@ -192,14 +202,18 @@ class GitLabPipe {
|
|
|
192
202
|
updateRun() {}
|
|
193
203
|
}
|
|
194
204
|
|
|
195
|
-
async function deletePreviousReport(
|
|
205
|
+
async function deletePreviousReport(client, commentsRequestURL, hiddenCommentData, token) {
|
|
196
206
|
if (process.env.GITLAB_KEEP_OUTDATED_REPORTS) return;
|
|
197
207
|
|
|
198
208
|
// get comments
|
|
199
209
|
let comments = [];
|
|
200
210
|
|
|
201
211
|
try {
|
|
202
|
-
const response = await
|
|
212
|
+
const response = await client.request({
|
|
213
|
+
method: 'GET',
|
|
214
|
+
url: commentsRequestURL,
|
|
215
|
+
params: { access_token: token }
|
|
216
|
+
});
|
|
203
217
|
comments = response.data;
|
|
204
218
|
} catch (e) {
|
|
205
219
|
console.error('Error while attempt to retrieve comments on GitLab Merge Request:\n', e);
|
|
@@ -212,8 +226,12 @@ async function deletePreviousReport(axiosInstance, commentsRequestURL, hiddenCom
|
|
|
212
226
|
if (comment.body.includes(hiddenCommentData)) {
|
|
213
227
|
try {
|
|
214
228
|
// delete previous comment
|
|
215
|
-
const deleteCommentURL = `${commentsRequestURL}/${comment.id}
|
|
216
|
-
await
|
|
229
|
+
const deleteCommentURL = `${commentsRequestURL}/${comment.id}`;
|
|
230
|
+
await client.request({
|
|
231
|
+
method: 'DELETE',
|
|
232
|
+
url: deleteCommentURL,
|
|
233
|
+
params: { access_token: token }
|
|
234
|
+
});
|
|
217
235
|
} catch (e) {
|
|
218
236
|
console.warn(`Can't delete previously added comment with testomat.io report. Ignore.`);
|
|
219
237
|
}
|
package/src/pipe/html.js
CHANGED
|
@@ -237,7 +237,6 @@ class HtmlPipe {
|
|
|
237
237
|
</select>`,
|
|
238
238
|
),
|
|
239
239
|
);
|
|
240
|
-
/* eslint-disable */
|
|
241
240
|
handlebars.registerHelper('emptyDataComponent', () => {
|
|
242
241
|
const svgFilePath = path.join(__dirname, '..', 'template', 'emptyData.svg');
|
|
243
242
|
const svgContent = fs.readFileSync(svgFilePath, 'utf8');
|
|
@@ -254,13 +253,12 @@ class HtmlPipe {
|
|
|
254
253
|
<div>`,
|
|
255
254
|
);
|
|
256
255
|
});
|
|
257
|
-
/* eslint-enable */
|
|
258
256
|
handlebars.registerHelper('pageDispleyElements', tests => {
|
|
259
257
|
// We wrapp the lines to the HTML format we need
|
|
260
258
|
const totalTests = JSON.parse(
|
|
261
259
|
JSON.stringify(tests)
|
|
262
260
|
.replace(/<script>/g, '<script>')
|
|
263
|
-
.replace(/<\/script>/g, '</script>'),
|
|
261
|
+
.replace(/<\/script>/g, '</script>'),
|
|
264
262
|
);
|
|
265
263
|
|
|
266
264
|
const paginationOptions = {
|
|
@@ -287,7 +285,6 @@ class HtmlPipe {
|
|
|
287
285
|
|
|
288
286
|
statuses.forEach(status => {
|
|
289
287
|
for (const option in paginationOptions) {
|
|
290
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
291
288
|
if (paginationOptions.hasOwnProperty(option)) {
|
|
292
289
|
const pageSize = paginationOptions[option];
|
|
293
290
|
let filteredItems = totalTests;
|
package/src/pipe/testomatio.js
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import createDebugMessages from 'debug';
|
|
2
2
|
import pc from 'picocolors';
|
|
3
|
-
|
|
4
|
-
// Retry interceptor function
|
|
5
|
-
import axiosRetry from 'axios-retry';
|
|
6
|
-
|
|
7
|
-
// Default axios instance
|
|
8
|
-
import axios from 'axios';
|
|
9
|
-
|
|
3
|
+
import { Gaxios } from 'gaxios';
|
|
10
4
|
import JsonCycle from 'json-cycle';
|
|
11
5
|
import { APP_PREFIX, STATUS, AXIOS_TIMEOUT, REPORTER_REQUEST_RETRIES } from '../constants.js';
|
|
12
|
-
import { isValidUrl, foundedTestLog } from '../utils/utils.js';
|
|
6
|
+
import { isValidUrl, foundedTestLog, readLatestRunId } from '../utils/utils.js';
|
|
13
7
|
import { parseFilterParams, generateFilterRequestParams, setS3Credentials } from '../utils/pipe_utils.js';
|
|
14
8
|
import { config } from '../config.js';
|
|
15
9
|
|
|
16
10
|
const debug = createDebugMessages('@testomatio/reporter:pipe:testomatio');
|
|
17
11
|
|
|
18
|
-
if (process.env.TESTOMATIO_RUN)
|
|
19
|
-
// process.env.runId = process.env.TESTOMATIO_RUN;
|
|
20
|
-
}
|
|
12
|
+
if (process.env.TESTOMATIO_RUN) process.env.runId = process.env.TESTOMATIO_RUN;
|
|
21
13
|
|
|
22
14
|
/**
|
|
23
15
|
* @typedef {import('../../types/types.js').Pipe} Pipe
|
|
@@ -59,50 +51,38 @@ class TestomatioPipe {
|
|
|
59
51
|
this.groupTitle = params.groupTitle || process.env.TESTOMATIO_RUNGROUP_TITLE;
|
|
60
52
|
this.env = process.env.TESTOMATIO_ENV;
|
|
61
53
|
this.label = process.env.TESTOMATIO_LABEL;
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
|
|
55
|
+
// Create a new instance of gaxios with a custom config
|
|
56
|
+
this.client = new Gaxios({
|
|
64
57
|
baseURL: `${this.url.trim()}`,
|
|
65
58
|
timeout: AXIOS_TIMEOUT,
|
|
66
|
-
proxy: proxy
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
proxy: proxy ? proxy.toString() : undefined,
|
|
60
|
+
retry: true,
|
|
61
|
+
retryConfig: {
|
|
62
|
+
retry: REPORTER_REQUEST_RETRIES.retriesPerRequest,
|
|
63
|
+
retryDelay: REPORTER_REQUEST_RETRIES.retryTimeout,
|
|
64
|
+
httpMethodsToRetry: ['GET','PUT','HEAD','OPTIONS','DELETE','POST'],
|
|
65
|
+
shouldRetry: (error) => {
|
|
66
|
+
if (!error.response) return false;
|
|
67
|
+
switch (error.response?.status) {
|
|
68
|
+
case 400: // Bad request (probably wrong API key)
|
|
69
|
+
case 404: // Test not matched
|
|
70
|
+
case 429: // Rate limit exceeded
|
|
71
|
+
case 500: // Internal server error
|
|
72
|
+
return false;
|
|
73
|
+
default:
|
|
74
|
+
break;
|
|
71
75
|
}
|
|
72
|
-
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// Pass the axios instance to the retry function
|
|
76
|
-
axiosRetry(this.axios, {
|
|
77
|
-
// do not use retries for unit tests
|
|
78
|
-
retries: REPORTER_REQUEST_RETRIES.retriesPerRequest, // Number of retries
|
|
79
|
-
shouldResetTimeout: true,
|
|
80
|
-
retryCondition: error => {
|
|
81
|
-
if (!error.response) return false;
|
|
82
|
-
switch (error.response?.status) {
|
|
83
|
-
case 400: // Bad request (probably wrong API key)
|
|
84
|
-
case 404: // Test not matched
|
|
85
|
-
case 429: // Rate limit exceeded
|
|
86
|
-
case 500: // Internal server error
|
|
87
|
-
return false;
|
|
88
|
-
default:
|
|
89
|
-
break;
|
|
76
|
+
return error.response?.status >= 401; // Retry on 401+ and 5xx
|
|
90
77
|
}
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
retryDelay: () => REPORTER_REQUEST_RETRIES.retryTimeout, // sum = 15sec
|
|
94
|
-
onRetry: async (retryCount, error) => {
|
|
95
|
-
this.retriesTimestamps.push(Date.now());
|
|
96
|
-
|
|
97
|
-
debug(`${error.message || `Request failed ${error.status}`}. Retry #${retryCount} ...`);
|
|
98
|
-
},
|
|
78
|
+
}
|
|
99
79
|
});
|
|
100
80
|
|
|
101
81
|
this.isEnabled = true;
|
|
102
82
|
// do not finish this run (for parallel testing)
|
|
103
83
|
this.proceed = process.env.TESTOMATIO_PROCEED;
|
|
104
84
|
this.jiraId = process.env.TESTOMATIO_JIRA_ID;
|
|
105
|
-
this.runId = params.runId || process.env.
|
|
85
|
+
this.runId = params.runId || process.env.TESTOMATIO_RUN;
|
|
106
86
|
this.createNewTests = params.createNewTests ?? !!process.env.TESTOMATIO_CREATE;
|
|
107
87
|
this.hasUnmatchedTests = false;
|
|
108
88
|
this.requestFailures = 0;
|
|
@@ -136,12 +116,15 @@ class TestomatioPipe {
|
|
|
136
116
|
return;
|
|
137
117
|
}
|
|
138
118
|
|
|
139
|
-
const resp = await this.
|
|
140
|
-
|
|
119
|
+
const resp = await this.client.request({
|
|
120
|
+
method: 'GET',
|
|
121
|
+
url: '/api/test_grep',
|
|
122
|
+
params: q
|
|
123
|
+
});
|
|
141
124
|
|
|
142
|
-
if (Array.isArray(data?.tests) && data?.tests?.length > 0) {
|
|
143
|
-
foundedTestLog(APP_PREFIX, data.tests);
|
|
144
|
-
return data.tests;
|
|
125
|
+
if (Array.isArray(resp.data?.tests) && resp.data?.tests?.length > 0) {
|
|
126
|
+
foundedTestLog(APP_PREFIX, resp.data.tests);
|
|
127
|
+
return resp.data.tests;
|
|
145
128
|
}
|
|
146
129
|
|
|
147
130
|
console.log(APP_PREFIX, `⛔ No tests found for your --filter --> ${type}=${id}`);
|
|
@@ -201,16 +184,23 @@ class TestomatioPipe {
|
|
|
201
184
|
if (this.runId) {
|
|
202
185
|
this.store.runId = this.runId;
|
|
203
186
|
debug(`Run with id ${this.runId} already created, updating...`);
|
|
204
|
-
const resp = await this.
|
|
187
|
+
const resp = await this.client.request({
|
|
188
|
+
method: 'PUT',
|
|
189
|
+
url: `/api/reporter/${this.runId}`,
|
|
190
|
+
data: runParams
|
|
191
|
+
});
|
|
205
192
|
if (resp.data.artifacts) setS3Credentials(resp.data.artifacts);
|
|
206
193
|
return;
|
|
207
194
|
}
|
|
208
195
|
|
|
209
196
|
debug('Creating run...');
|
|
210
197
|
try {
|
|
211
|
-
const resp = await this.
|
|
198
|
+
const resp = await this.client.request({
|
|
199
|
+
method: 'POST',
|
|
200
|
+
url: '/api/reporter',
|
|
201
|
+
data: runParams,
|
|
212
202
|
maxContentLength: Infinity,
|
|
213
|
-
|
|
203
|
+
responseType: 'json'
|
|
214
204
|
});
|
|
215
205
|
|
|
216
206
|
this.runId = resp.data.uid;
|
|
@@ -227,6 +217,7 @@ class TestomatioPipe {
|
|
|
227
217
|
debug('Run created', this.runId);
|
|
228
218
|
} catch (err) {
|
|
229
219
|
const errorText = err.response?.data?.message || err.message;
|
|
220
|
+
debug('Error creating run', err);
|
|
230
221
|
console.log(errorText || err);
|
|
231
222
|
if (!this.apiKey) console.error('Testomat.io API key is not set');
|
|
232
223
|
if (!this.apiKey?.startsWith('tstmt')) console.error('Testomat.io API key is invalid');
|
|
@@ -273,7 +264,15 @@ class TestomatioPipe {
|
|
|
273
264
|
|
|
274
265
|
debug('Adding test', json);
|
|
275
266
|
|
|
276
|
-
return this.
|
|
267
|
+
return this.client.request({
|
|
268
|
+
method: 'POST',
|
|
269
|
+
url: `/api/reporter/${this.runId}/testrun`,
|
|
270
|
+
data: json,
|
|
271
|
+
headers: {
|
|
272
|
+
'Content-Type': 'application/json',
|
|
273
|
+
},
|
|
274
|
+
maxContentLength: Infinity
|
|
275
|
+
}).catch(err => {
|
|
277
276
|
this.requestFailures++;
|
|
278
277
|
this.notReportedTestsCount++;
|
|
279
278
|
if (err.response) {
|
|
@@ -325,57 +324,72 @@ class TestomatioPipe {
|
|
|
325
324
|
const testsToSend = this.batch.tests.splice(0);
|
|
326
325
|
debug('📨 Batch upload', testsToSend.length, 'tests');
|
|
327
326
|
|
|
328
|
-
return this.
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
this.hasUnmatchedTests = true;
|
|
347
|
-
}
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
327
|
+
return this.client.request({
|
|
328
|
+
method: 'POST',
|
|
329
|
+
url: `/api/reporter/${this.runId}/testrun`,
|
|
330
|
+
data: {
|
|
331
|
+
api_key: this.apiKey,
|
|
332
|
+
tests: testsToSend,
|
|
333
|
+
batch_index: this.batch.batchIndex
|
|
334
|
+
},
|
|
335
|
+
headers: {
|
|
336
|
+
'Content-Type': 'application/json',
|
|
337
|
+
},
|
|
338
|
+
maxContentLength: Infinity
|
|
339
|
+
}).catch(err => {
|
|
340
|
+
this.requestFailures++;
|
|
341
|
+
this.notReportedTestsCount += testsToSend.length;
|
|
342
|
+
if (err.response) {
|
|
343
|
+
if (err.response.status >= 400) {
|
|
344
|
+
const responseData = err.response.data || { message: '' };
|
|
350
345
|
console.log(
|
|
351
346
|
APP_PREFIX,
|
|
352
|
-
pc.yellow(`Warning: (${err.response
|
|
353
|
-
`Report couldn't be processed: ${err?.response?.data?.message}`,
|
|
347
|
+
pc.yellow(`Warning: ${responseData.message} (${err.response.status})`),
|
|
354
348
|
);
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
349
|
+
if (err.response?.data?.message?.includes('could not be matched')) {
|
|
350
|
+
this.hasUnmatchedTests = true;
|
|
351
|
+
}
|
|
352
|
+
return;
|
|
358
353
|
}
|
|
359
|
-
|
|
354
|
+
console.log(
|
|
355
|
+
APP_PREFIX,
|
|
356
|
+
pc.yellow(`Warning: (${err.response?.status})`),
|
|
357
|
+
`Report couldn't be processed: ${err?.response?.data?.message}`,
|
|
358
|
+
);
|
|
359
|
+
printCreateIssue(err);
|
|
360
|
+
} else {
|
|
361
|
+
console.log(APP_PREFIX, "Report couldn't be processed", err);
|
|
362
|
+
}
|
|
363
|
+
});
|
|
360
364
|
};
|
|
361
365
|
|
|
362
366
|
/**
|
|
363
367
|
* Adds a test to the batch uploader (or reports a single test if batch uploading is disabled)
|
|
364
368
|
*/
|
|
365
369
|
addTest(data) {
|
|
370
|
+
this.isEnabled = !!(this.apiKey ?? this.isEnabled);
|
|
366
371
|
if (!this.isEnabled) return;
|
|
367
|
-
|
|
372
|
+
|
|
373
|
+
this.runId = this.runId || process.env.runId || this.store.runId || readLatestRunId();
|
|
374
|
+
if (!this.runId) {
|
|
375
|
+
console.warn(APP_PREFIX, pc.red('Run ID is not set, skipping test reporting'));
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
368
378
|
|
|
369
379
|
// add test ID + run ID
|
|
370
380
|
if (data.rid) data.rid = `${this.runId}-${data.rid}`;
|
|
371
381
|
data.api_key = this.apiKey;
|
|
372
382
|
data.create = this.createNewTests;
|
|
373
383
|
|
|
374
|
-
|
|
384
|
+
let uploading = null;
|
|
385
|
+
if (!this.batch.isEnabled) uploading = this.#uploadSingleTest(data);
|
|
375
386
|
else this.batch.tests.push(data);
|
|
376
387
|
|
|
377
388
|
// if test is added after run which is already finished
|
|
378
|
-
|
|
389
|
+
if (!this.batch.intervalFunction) uploading = this.#batchUpload();
|
|
390
|
+
|
|
391
|
+
// return promise to be able to wait for it
|
|
392
|
+
return uploading;
|
|
379
393
|
}
|
|
380
394
|
|
|
381
395
|
/**
|
|
@@ -415,12 +429,16 @@ class TestomatioPipe {
|
|
|
415
429
|
|
|
416
430
|
try {
|
|
417
431
|
if (this.runId && !this.proceed) {
|
|
418
|
-
await this.
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
432
|
+
await this.client.request({
|
|
433
|
+
method: 'PUT',
|
|
434
|
+
url: `/api/reporter/${this.runId}`,
|
|
435
|
+
data: {
|
|
436
|
+
api_key: this.apiKey,
|
|
437
|
+
duration: params.duration,
|
|
438
|
+
status_event,
|
|
439
|
+
detach: params.detach,
|
|
440
|
+
tests: params.tests,
|
|
441
|
+
}
|
|
424
442
|
});
|
|
425
443
|
if (this.runUrl) {
|
|
426
444
|
console.log(APP_PREFIX, '📊 Report Saved. Report URL:', pc.magenta(this.runUrl));
|
|
@@ -437,14 +455,11 @@ class TestomatioPipe {
|
|
|
437
455
|
|
|
438
456
|
if (this.hasUnmatchedTests) {
|
|
439
457
|
console.log('');
|
|
440
|
-
// eslint-disable-next-line max-len
|
|
441
458
|
console.log(APP_PREFIX, pc.yellow(pc.bold('⚠️ Some reported tests were not found in Testomat.io project')));
|
|
442
|
-
// eslint-disable-next-line max-len
|
|
443
459
|
console.log(
|
|
444
460
|
APP_PREFIX,
|
|
445
461
|
`If you use Testomat.io as a reporter only, please re-run tests using ${pc.bold('TESTOMATIO_CREATE=1')}`,
|
|
446
462
|
);
|
|
447
|
-
// eslint-disable-next-line max-len
|
|
448
463
|
console.log(
|
|
449
464
|
APP_PREFIX,
|
|
450
465
|
`But to keep your tests consistent it is recommended to ${pc.bold('import tests first')}`,
|
|
@@ -453,7 +468,6 @@ class TestomatioPipe {
|
|
|
453
468
|
console.log(APP_PREFIX, 'You can do that automatically via command line tools:');
|
|
454
469
|
console.log(APP_PREFIX, pc.bold('npx check-tests ... --update-ids'), 'See: https://bit.ly/js-update-ids');
|
|
455
470
|
console.log(APP_PREFIX, 'or for Cucumber:');
|
|
456
|
-
// eslint-disable-next-line max-len
|
|
457
471
|
console.log(APP_PREFIX, pc.bold('npx check-cucumber ... --update-ids'), 'See: https://bit.ly/bdd-update-ids');
|
|
458
472
|
}
|
|
459
473
|
} catch (err) {
|
|
@@ -478,26 +492,17 @@ function printCreateIssue(err) {
|
|
|
478
492
|
console.log(
|
|
479
493
|
APP_PREFIX,
|
|
480
494
|
'If you think this is a bug please create an issue: https://github.com/testomatio/reporter/issues/new',
|
|
481
|
-
);
|
|
495
|
+
);
|
|
482
496
|
console.log(APP_PREFIX, 'Provide this information:');
|
|
483
497
|
console.log('Error:', err.message || err.code);
|
|
484
498
|
if (!err.config) return;
|
|
485
499
|
|
|
486
500
|
const time = new Date().toUTCString();
|
|
487
|
-
const {
|
|
501
|
+
const { body, url, baseURL, method } = err?.config || {};
|
|
488
502
|
console.log('```js');
|
|
489
|
-
console.log({
|
|
503
|
+
console.log({ body: body?.replace(/"(tstmt_[^"]+)"/g, 'tstmt_*'), url, baseURL, method, time });
|
|
490
504
|
console.log('```');
|
|
491
505
|
});
|
|
492
506
|
}
|
|
493
507
|
|
|
494
|
-
const axiosAddTestrunRequestConfig = {
|
|
495
|
-
maxContentLength: Infinity,
|
|
496
|
-
maxBodyLength: Infinity,
|
|
497
|
-
headers: {
|
|
498
|
-
// Overwrite Axios's automatically set Content-Type
|
|
499
|
-
'Content-Type': 'application/json',
|
|
500
|
-
},
|
|
501
|
-
};
|
|
502
|
-
|
|
503
508
|
export default TestomatioPipe;
|