@testomatio/reporter 2.0.1-beta.4 → 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/pipe/testomatio.js
CHANGED
|
@@ -1,453 +1,498 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
const debug = require('debug')('@testomatio/reporter:pipe:testomatio');
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
// Retry interceptor function
|
|
4
|
+
const axiosRetry = require('axios-retry');
|
|
5
|
+
// Default axios instance
|
|
6
|
+
const axios = require('axios');
|
|
7
|
+
const JsonCycle = require('json-cycle');
|
|
8
|
+
|
|
9
|
+
const { APP_PREFIX, STATUS, AXIOS_TIMEOUT, REPORTER_REQUEST_RETRIES } = require('../constants');
|
|
10
|
+
const { isValidUrl, foundedTestLog } = require('../utils/utils');
|
|
11
|
+
const { parseFilterParams, generateFilterRequestParams, setS3Credentials } = require('../utils/pipe_utils');
|
|
12
|
+
const config = require('../config');
|
|
13
|
+
|
|
14
|
+
if (process.env.TESTOMATIO_RUN) {
|
|
15
|
+
process.env.runId = process.env.TESTOMATIO_RUN;
|
|
16
|
+
}
|
|
17
|
+
|
|
17
18
|
/**
|
|
18
|
-
* @typedef {import('../../types
|
|
19
|
-
* @typedef {import('../../types
|
|
19
|
+
* @typedef {import('../../types').Pipe} Pipe
|
|
20
|
+
* @typedef {import('../../types').TestData} TestData
|
|
20
21
|
* @class TestomatioPipe
|
|
21
22
|
* @implements {Pipe}
|
|
22
23
|
*/
|
|
23
24
|
class TestomatioPipe {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
debug('Testomatio Pipe: Enabled');
|
|
44
|
-
const proxyUrl = process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
|
|
45
|
-
const proxy = proxyUrl ? new URL(proxyUrl) : null;
|
|
46
|
-
this.parallel = params.parallel;
|
|
47
|
-
this.store = store || {};
|
|
48
|
-
this.title = params.title || process.env.TESTOMATIO_TITLE;
|
|
49
|
-
this.sharedRun = !!process.env.TESTOMATIO_SHARED_RUN;
|
|
50
|
-
this.sharedRunTimeout = !!process.env.TESTOMATIO_SHARED_RUN_TIMEOUT;
|
|
51
|
-
this.groupTitle = params.groupTitle || process.env.TESTOMATIO_RUNGROUP_TITLE;
|
|
52
|
-
this.env = process.env.TESTOMATIO_ENV;
|
|
53
|
-
this.label = process.env.TESTOMATIO_LABEL;
|
|
54
|
-
// Create a new instance of gaxios with a custom config
|
|
55
|
-
this.client = new gaxios_1.Gaxios({
|
|
56
|
-
baseURL: `${this.url.trim()}`,
|
|
57
|
-
timeout: constants_js_1.AXIOS_TIMEOUT,
|
|
58
|
-
proxy: proxy ? proxy.toString() : undefined,
|
|
59
|
-
retry: true,
|
|
60
|
-
retryConfig: {
|
|
61
|
-
retry: constants_js_1.REPORTER_REQUEST_RETRIES.retriesPerRequest,
|
|
62
|
-
retryDelay: constants_js_1.REPORTER_REQUEST_RETRIES.retryTimeout,
|
|
63
|
-
httpMethodsToRetry: ['GET', 'PUT', 'HEAD', 'OPTIONS', 'DELETE', 'POST'],
|
|
64
|
-
shouldRetry: (error) => {
|
|
65
|
-
if (!error.response)
|
|
66
|
-
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;
|
|
75
|
-
}
|
|
76
|
-
return error.response?.status >= 401; // Retry on 401+ and 5xx
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
this.isEnabled = true;
|
|
81
|
-
// do not finish this run (for parallel testing)
|
|
82
|
-
this.proceed = process.env.TESTOMATIO_PROCEED;
|
|
83
|
-
this.jiraId = process.env.TESTOMATIO_JIRA_ID;
|
|
84
|
-
this.runId = params.runId || process.env.TESTOMATIO_RUN;
|
|
85
|
-
this.createNewTests = params.createNewTests ?? !!process.env.TESTOMATIO_CREATE;
|
|
86
|
-
this.hasUnmatchedTests = false;
|
|
87
|
-
this.requestFailures = 0;
|
|
88
|
-
if (!(0, utils_js_1.isValidUrl)(this.url.trim())) {
|
|
89
|
-
this.isEnabled = false;
|
|
90
|
-
console.error(constants_js_1.APP_PREFIX, picocolors_1.default.red(`Error creating report on Testomat.io, report url '${this.url}' is invalid`));
|
|
91
|
-
}
|
|
25
|
+
constructor(params, store) {
|
|
26
|
+
this.batch = {
|
|
27
|
+
isEnabled: params.isBatchEnabled ?? !process.env.TESTOMATIO_DISABLE_BATCH_UPLOAD ?? true,
|
|
28
|
+
intervalFunction: null, // will be created in createRun by setInterval function
|
|
29
|
+
intervalTime: 5000, // how often tests are sent
|
|
30
|
+
tests: [], // array of tests in batch
|
|
31
|
+
batchIndex: 0, // represents the current batch index (starts from 1 and increments by 1 for each batch)
|
|
32
|
+
};
|
|
33
|
+
this.retriesTimestamps = [];
|
|
34
|
+
this.reportingCanceledDueToReqFailures = false;
|
|
35
|
+
this.notReportedTestsCount = 0;
|
|
36
|
+
|
|
37
|
+
this.isEnabled = false;
|
|
38
|
+
this.url = params.testomatioUrl || process.env.TESTOMATIO_URL || 'https://app.testomat.io';
|
|
39
|
+
this.apiKey = params.apiKey || config.TESTOMATIO;
|
|
40
|
+
|
|
41
|
+
if (!this.apiKey) {
|
|
42
|
+
return;
|
|
92
43
|
}
|
|
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
|
-
|
|
44
|
+
debug('Testomatio Pipe: Enabled');
|
|
45
|
+
|
|
46
|
+
const proxyUrl = process.env.HTTP_PROXY || process.env.HTTPS_PROXY;
|
|
47
|
+
const proxy = proxyUrl ? new URL(proxyUrl) : null;
|
|
48
|
+
|
|
49
|
+
this.parallel = params.parallel;
|
|
50
|
+
this.store = store || {};
|
|
51
|
+
this.title = params.title || process.env.TESTOMATIO_TITLE;
|
|
52
|
+
this.sharedRun = !!process.env.TESTOMATIO_SHARED_RUN;
|
|
53
|
+
this.sharedRunTimeout = !!process.env.TESTOMATIO_SHARED_RUN_TIMEOUT;
|
|
54
|
+
this.groupTitle = params.groupTitle || process.env.TESTOMATIO_RUNGROUP_TITLE;
|
|
55
|
+
this.env = process.env.TESTOMATIO_ENV;
|
|
56
|
+
this.label = process.env.TESTOMATIO_LABEL;
|
|
57
|
+
// Create a new instance of axios with a custom config
|
|
58
|
+
this.axios = axios.create({
|
|
59
|
+
baseURL: `${this.url.trim()}`,
|
|
60
|
+
timeout: AXIOS_TIMEOUT,
|
|
61
|
+
proxy: proxy ? {
|
|
62
|
+
host: proxy.hostname,
|
|
63
|
+
port: proxy.port,
|
|
64
|
+
protocol: proxy.protocol,
|
|
65
|
+
} : false,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Pass the axios instance to the retry function
|
|
69
|
+
axiosRetry(this.axios, {
|
|
70
|
+
// do not use retries for unit tests
|
|
71
|
+
retries: REPORTER_REQUEST_RETRIES.retriesPerRequest, // Number of retries
|
|
72
|
+
shouldResetTimeout: true,
|
|
73
|
+
retryCondition: error => {
|
|
74
|
+
if (!error.response) return false;
|
|
75
|
+
switch (error.response?.status) {
|
|
76
|
+
case 400: // Bad request (probably wrong API key)
|
|
77
|
+
case 404: // Test not matched
|
|
78
|
+
case 429: // Rate limit exceeded
|
|
79
|
+
case 500: // Internal server error
|
|
80
|
+
return false;
|
|
81
|
+
default:
|
|
82
|
+
break;
|
|
126
83
|
}
|
|
84
|
+
return error.response?.status >= 401; // Retry on 401+ and 5xx
|
|
85
|
+
},
|
|
86
|
+
retryDelay: () => REPORTER_REQUEST_RETRIES.retryTimeout, // sum = 15sec
|
|
87
|
+
onRetry: async (retryCount, error) => {
|
|
88
|
+
this.retriesTimestamps.push(Date.now());
|
|
89
|
+
|
|
90
|
+
debug(`${error.message || `Request failed ${error.status}`}. Retry #${retryCount} ...`);
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
this.isEnabled = true;
|
|
95
|
+
// do not finish this run (for parallel testing)
|
|
96
|
+
this.proceed = process.env.TESTOMATIO_PROCEED;
|
|
97
|
+
this.jiraId = process.env.TESTOMATIO_JIRA_ID;
|
|
98
|
+
this.runId = params.runId || process.env.runId;
|
|
99
|
+
this.createNewTests = params.createNewTests ?? !!process.env.TESTOMATIO_CREATE;
|
|
100
|
+
this.hasUnmatchedTests = false;
|
|
101
|
+
this.requestFailures = 0;
|
|
102
|
+
|
|
103
|
+
if (!isValidUrl(this.url.trim())) {
|
|
104
|
+
this.isEnabled = false;
|
|
105
|
+
console.error(APP_PREFIX, chalk.red(`Error creating report on Testomat.io, report url '${this.url}' is invalid`));
|
|
127
106
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
label: this.label,
|
|
165
|
-
shared_run: this.sharedRun,
|
|
166
|
-
shared_run_timeout: this.sharedRunTimeout,
|
|
167
|
-
}).filter(([, value]) => !!value));
|
|
168
|
-
debug(' >>>>>> Run params', JSON.stringify(runParams, null, 2));
|
|
169
|
-
if (this.runId) {
|
|
170
|
-
this.store.runId = this.runId;
|
|
171
|
-
debug(`Run with id ${this.runId} already created, updating...`);
|
|
172
|
-
const resp = await this.client.request({
|
|
173
|
-
method: 'PUT',
|
|
174
|
-
url: `/api/reporter/${this.runId}`,
|
|
175
|
-
data: runParams
|
|
176
|
-
});
|
|
177
|
-
if (resp.data.artifacts)
|
|
178
|
-
(0, pipe_utils_js_1.setS3Credentials)(resp.data.artifacts);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
debug('Creating run...');
|
|
182
|
-
try {
|
|
183
|
-
const resp = await this.client.request({
|
|
184
|
-
method: 'POST',
|
|
185
|
-
url: '/api/reporter',
|
|
186
|
-
data: runParams,
|
|
187
|
-
maxContentLength: Infinity,
|
|
188
|
-
responseType: 'json'
|
|
189
|
-
});
|
|
190
|
-
this.runId = resp.data.uid;
|
|
191
|
-
this.runUrl = `${this.url}/${resp.data.url.split('/').splice(3).join('/')}`;
|
|
192
|
-
this.runPublicUrl = resp.data.public_url;
|
|
193
|
-
if (resp.data.artifacts)
|
|
194
|
-
(0, pipe_utils_js_1.setS3Credentials)(resp.data.artifacts);
|
|
195
|
-
this.store.runUrl = this.runUrl;
|
|
196
|
-
this.store.runPublicUrl = this.runPublicUrl;
|
|
197
|
-
this.store.runId = this.runId;
|
|
198
|
-
console.log(constants_js_1.APP_PREFIX, '📊 Report created. Report ID:', this.runId);
|
|
199
|
-
process.env.runId = this.runId;
|
|
200
|
-
debug('Run created', this.runId);
|
|
201
|
-
}
|
|
202
|
-
catch (err) {
|
|
203
|
-
const errorText = err.response?.data?.message || err.message;
|
|
204
|
-
debug('Error creating run', err);
|
|
205
|
-
console.log(errorText || err);
|
|
206
|
-
if (!this.apiKey)
|
|
207
|
-
console.error('Testomat.io API key is not set');
|
|
208
|
-
if (!this.apiKey?.startsWith('tstmt'))
|
|
209
|
-
console.error('Testomat.io API key is invalid');
|
|
210
|
-
console.error(constants_js_1.APP_PREFIX, 'Error creating Testomat.io report (see details above), please check if your API key is valid. Skipping report');
|
|
211
|
-
printCreateIssue(err);
|
|
212
|
-
}
|
|
213
|
-
debug('"createRun" function finished');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Asynchronously prepares and retrieves the Testomat.io test grepList based on the provided options.
|
|
111
|
+
* @param {Object} opts - The options for preparing the test grepList.
|
|
112
|
+
* @returns {Promise<string[]>} - An array containing the retrieved
|
|
113
|
+
* test grepList, or an empty array if no tests are found or the request is disabled.
|
|
114
|
+
* @throws {Error} - Throws an error if there was a problem while making the request.
|
|
115
|
+
*/
|
|
116
|
+
async prepareRun(opts) {
|
|
117
|
+
if (!this.isEnabled) return [];
|
|
118
|
+
|
|
119
|
+
const { type, id } = parseFilterParams(opts);
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
const q = generateFilterRequestParams({
|
|
123
|
+
type,
|
|
124
|
+
id,
|
|
125
|
+
apiKey: this.apiKey.trim(),
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
if (!q) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const resp = await this.axios.get('/api/test_grep', q);
|
|
133
|
+
const { data } = resp;
|
|
134
|
+
|
|
135
|
+
if (Array.isArray(data?.tests) && data?.tests?.length > 0) {
|
|
136
|
+
foundedTestLog(APP_PREFIX, data.tests);
|
|
137
|
+
return data.tests;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
console.log(APP_PREFIX, `⛔ No tests found for your --filter --> ${type}=${id}`);
|
|
141
|
+
} catch (err) {
|
|
142
|
+
console.error(APP_PREFIX, `🚩 Error getting Testomat.io test grepList: ${err}`);
|
|
214
143
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Creates a new run on Testomat.io
|
|
148
|
+
* @param {{isBatchEnabled?: boolean}} params
|
|
149
|
+
* @returns Promise<void>
|
|
150
|
+
*/
|
|
151
|
+
async createRun(params = {}) {
|
|
152
|
+
this.batch.isEnabled = params.isBatchEnabled ?? this.batch.isEnabled;
|
|
153
|
+
if (!this.isEnabled) return;
|
|
154
|
+
if (this.batch.isEnabled) this.batch.intervalFunction = setInterval(this.#batchUpload, this.batch.intervalTime);
|
|
155
|
+
|
|
156
|
+
let buildUrl = process.env.BUILD_URL || process.env.CI_JOB_URL || process.env.CIRCLE_BUILD_URL;
|
|
157
|
+
|
|
158
|
+
// GitHub Actions Url
|
|
159
|
+
if (!buildUrl && process.env.GITHUB_RUN_ID) {
|
|
160
|
+
// eslint-disable-next-line max-len
|
|
161
|
+
buildUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
|
|
230
162
|
}
|
|
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
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
163
|
+
|
|
164
|
+
// Azure DevOps Url
|
|
165
|
+
if (!buildUrl && process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI) {
|
|
166
|
+
const collectionUri = process.env.SYSTEM_TEAMFOUNDATIONCOLLECTIONURI;
|
|
167
|
+
const project = process.env.SYSTEM_TEAMPROJECT;
|
|
168
|
+
const buildId = process.env.BUILD_BUILDID;
|
|
169
|
+
buildUrl = `${collectionUri}/${project}/_build/results?buildId=${buildId}`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (buildUrl && !buildUrl.startsWith('http')) buildUrl = undefined;
|
|
173
|
+
|
|
174
|
+
const accessEvent = process.env.TESTOMATIO_PUBLISH ? 'publish' : null;
|
|
175
|
+
|
|
176
|
+
const runParams = Object.fromEntries(
|
|
177
|
+
Object.entries({
|
|
178
|
+
ci_build_url: buildUrl,
|
|
179
|
+
parallel: this.parallel,
|
|
180
|
+
api_key: this.apiKey.trim(),
|
|
181
|
+
group_title: this.groupTitle,
|
|
182
|
+
access_event: accessEvent,
|
|
183
|
+
jira_id: this.jiraId,
|
|
184
|
+
env: this.env,
|
|
185
|
+
title: this.title,
|
|
186
|
+
label: this.label,
|
|
187
|
+
shared_run: this.sharedRun,
|
|
188
|
+
shared_run_timeout: this.sharedRunTimeout,
|
|
189
|
+
}).filter(([, value]) => !!value),
|
|
190
|
+
);
|
|
191
|
+
debug('Run params', JSON.stringify(runParams, null, 2));
|
|
192
|
+
|
|
193
|
+
if (this.runId) {
|
|
194
|
+
this.store.runId = this.runId;
|
|
195
|
+
debug(`Run with id ${this.runId} already created, updating...`);
|
|
196
|
+
const resp = await this.axios.put(`/api/reporter/${this.runId}`, runParams);
|
|
197
|
+
if (resp.data.artifacts) setS3Credentials(resp.data.artifacts);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
debug('Creating run...');
|
|
202
|
+
try {
|
|
203
|
+
const resp = await this.axios.post(`/api/reporter`, runParams, {
|
|
204
|
+
maxContentLength: Infinity,
|
|
205
|
+
maxBodyLength: Infinity,
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
this.runId = resp.data.uid;
|
|
209
|
+
this.runUrl = `${this.url}/${resp.data.url.split('/').splice(3).join('/')}`;
|
|
210
|
+
this.runPublicUrl = resp.data.public_url;
|
|
211
|
+
|
|
212
|
+
if (resp.data.artifacts) setS3Credentials(resp.data.artifacts);
|
|
213
|
+
|
|
214
|
+
this.store.runUrl = this.runUrl;
|
|
215
|
+
this.store.runPublicUrl = this.runPublicUrl;
|
|
216
|
+
this.store.runId = this.runId;
|
|
217
|
+
console.log(APP_PREFIX, '📊 Report created. Report ID:', this.runId);
|
|
218
|
+
process.env.runId = this.runId;
|
|
219
|
+
debug('Run created', this.runId);
|
|
220
|
+
} catch (err) {
|
|
221
|
+
const errorText = err.response?.data?.message || err.message;
|
|
222
|
+
console.log(errorText || err);
|
|
223
|
+
if (!this.apiKey) console.error('Testomat.io API key is not set');
|
|
224
|
+
if (!this.apiKey?.startsWith('tstmt')) console.error('Testomat.io API key is invalid');
|
|
225
|
+
console.error(
|
|
226
|
+
APP_PREFIX,
|
|
227
|
+
'Error creating Testomat.io report (see details above), please check if your API key is valid. Skipping report'
|
|
228
|
+
);
|
|
229
|
+
printCreateIssue(err);
|
|
230
|
+
}
|
|
231
|
+
debug('"createRun" function finished');
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Decides whether to skip test reporting in case of too many request failures
|
|
236
|
+
* @returns {boolean}
|
|
237
|
+
*/
|
|
238
|
+
#cancelTestReportingInCaseOfTooManyReqFailures() {
|
|
239
|
+
if (!process.env.TESTOMATIO_MAX_REQUEST_FAILURES) return;
|
|
240
|
+
|
|
241
|
+
const cancelReporting = this.requestFailures >= parseInt(process.env.TESTOMATIO_MAX_REQUEST_FAILURES, 10);
|
|
242
|
+
if (cancelReporting) {
|
|
243
|
+
this.reportingCanceledDueToReqFailures = true;
|
|
244
|
+
const errorMessage =
|
|
245
|
+
`⚠️ ${process.env.TESTOMATIO_MAX_REQUEST_FAILURES} requests were failed, reporting to Testomat aborted.`;
|
|
246
|
+
console.warn(`${APP_PREFIX} ${chalk.yellow(errorMessage)}`);
|
|
247
|
+
}
|
|
248
|
+
return cancelReporting;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
#uploadSingleTest = async data => {
|
|
252
|
+
if (!this.isEnabled) return;
|
|
253
|
+
if (!this.runId) return;
|
|
254
|
+
if (this.#cancelTestReportingInCaseOfTooManyReqFailures()) return;
|
|
255
|
+
|
|
256
|
+
data.api_key = this.apiKey;
|
|
257
|
+
data.create = this.createNewTests;
|
|
258
|
+
|
|
259
|
+
if (!process.env.TESTOMATIO_STACK_PASSED && data.status === STATUS.PASSED) {
|
|
260
|
+
data.stack = null;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const json = JsonCycle.stringify(data);
|
|
264
|
+
|
|
265
|
+
debug('Adding test', json);
|
|
266
|
+
|
|
267
|
+
return this.axios
|
|
268
|
+
.post(`/api/reporter/${this.runId}/testrun`, json, axiosAddTestrunRequestConfig)
|
|
269
|
+
.catch(err => {
|
|
270
|
+
this.requestFailures++;
|
|
271
|
+
this.notReportedTestsCount++;
|
|
272
|
+
if (err.response) {
|
|
273
|
+
if (err.response.status >= 400) {
|
|
274
|
+
const responseData = err.response.data || { message: '' };
|
|
275
|
+
console.log(
|
|
276
|
+
APP_PREFIX,
|
|
277
|
+
chalk.yellow(`Warning: ${responseData.message} (${err.response.status})`),
|
|
278
|
+
chalk.grey(data?.title || ''),
|
|
279
|
+
);
|
|
280
|
+
if (err.response?.data?.message?.includes('could not be matched')) {
|
|
281
|
+
this.hasUnmatchedTests = true;
|
|
270
282
|
}
|
|
271
|
-
});
|
|
272
|
-
};
|
|
273
|
-
/**
|
|
274
|
-
* Uploads tests as a batch (multiple tests at once). Intended to be used with a setInterval
|
|
275
|
-
*/
|
|
276
|
-
#batchUpload = async () => {
|
|
277
|
-
if (!this.batch.isEnabled)
|
|
278
|
-
return;
|
|
279
|
-
if (!this.batch.tests.length)
|
|
280
|
-
return;
|
|
281
|
-
if (this.#cancelTestReportingInCaseOfTooManyReqFailures())
|
|
282
283
|
return;
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
284
|
+
}
|
|
285
|
+
console.log(
|
|
286
|
+
APP_PREFIX,
|
|
287
|
+
chalk.yellow(`Warning: ${data?.title || ''} (${err.response?.status})`),
|
|
288
|
+
`Report couldn't be processed: ${err?.response?.data?.message}`,
|
|
289
|
+
);
|
|
290
|
+
printCreateIssue(err);
|
|
291
|
+
} else {
|
|
292
|
+
console.log(APP_PREFIX, chalk.blue(data?.title || ''), "Report couldn't be processed", err);
|
|
288
293
|
}
|
|
289
|
-
|
|
290
|
-
debug('📨 Batch upload: no tests to send');
|
|
291
|
-
this.batch.numberOfTimesCalledWithoutTests++;
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
this.batch.batchIndex++;
|
|
295
|
-
// get tests from batch and clear batch
|
|
296
|
-
const testsToSend = this.batch.tests.splice(0);
|
|
297
|
-
debug('📨 Batch upload', testsToSend.length, 'tests');
|
|
298
|
-
return this.client.request({
|
|
299
|
-
method: 'POST',
|
|
300
|
-
url: `/api/reporter/${this.runId}/testrun`,
|
|
301
|
-
data: {
|
|
302
|
-
api_key: this.apiKey,
|
|
303
|
-
tests: testsToSend,
|
|
304
|
-
batch_index: this.batch.batchIndex
|
|
305
|
-
},
|
|
306
|
-
headers: {
|
|
307
|
-
'Content-Type': 'application/json',
|
|
308
|
-
},
|
|
309
|
-
maxContentLength: Infinity
|
|
310
|
-
}).catch(err => {
|
|
311
|
-
this.requestFailures++;
|
|
312
|
-
this.notReportedTestsCount += testsToSend.length;
|
|
313
|
-
if (err.response) {
|
|
314
|
-
if (err.response.status >= 400) {
|
|
315
|
-
const responseData = err.response.data || { message: '' };
|
|
316
|
-
console.log(constants_js_1.APP_PREFIX, picocolors_1.default.yellow(`Warning: ${responseData.message} (${err.response.status})`));
|
|
317
|
-
if (err.response?.data?.message?.includes('could not be matched')) {
|
|
318
|
-
this.hasUnmatchedTests = true;
|
|
319
|
-
}
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
console.log(constants_js_1.APP_PREFIX, picocolors_1.default.yellow(`Warning: (${err.response?.status})`), `Report couldn't be processed: ${err?.response?.data?.message}`);
|
|
323
|
-
printCreateIssue(err);
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
console.log(constants_js_1.APP_PREFIX, "Report couldn't be processed", err);
|
|
327
|
-
}
|
|
328
|
-
});
|
|
294
|
+
});
|
|
329
295
|
};
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Uploads tests as a batch (multiple tests at once). Intended to be used with a setInterval
|
|
300
|
+
*/
|
|
301
|
+
#batchUpload = async () => {
|
|
302
|
+
this.batch.batchIndex++;
|
|
303
|
+
if (!this.batch.isEnabled) return;
|
|
304
|
+
if (!this.batch.tests.length) return;
|
|
305
|
+
if (this.#cancelTestReportingInCaseOfTooManyReqFailures()) return;
|
|
306
|
+
|
|
307
|
+
// get tests from batch and clear batch
|
|
308
|
+
const testsToSend = this.batch.tests.splice(0);
|
|
309
|
+
debug('📨 Batch upload', testsToSend.length, 'tests');
|
|
310
|
+
|
|
311
|
+
testsToSend.forEach(debug);
|
|
312
|
+
|
|
313
|
+
return this.axios
|
|
314
|
+
.post(
|
|
315
|
+
`/api/reporter/${this.runId}/testrun`,
|
|
316
|
+
{ api_key: this.apiKey, tests: testsToSend, batch_index: this.batch.batchIndex },
|
|
317
|
+
axiosAddTestrunRequestConfig,
|
|
318
|
+
)
|
|
319
|
+
.catch(err => {
|
|
320
|
+
this.requestFailures++;
|
|
321
|
+
this.notReportedTestsCount += testsToSend.length;
|
|
322
|
+
if (err.response) {
|
|
323
|
+
if (err.response.status >= 400) {
|
|
324
|
+
const responseData = err.response.data || { message: '' };
|
|
325
|
+
console.log(
|
|
326
|
+
APP_PREFIX,
|
|
327
|
+
chalk.yellow(`Warning: ${responseData.message} (${err.response.status})`),
|
|
328
|
+
// chalk.grey(data?.title || ''),
|
|
329
|
+
);
|
|
330
|
+
if (err.response?.data?.message?.includes('could not be matched')) {
|
|
331
|
+
this.hasUnmatchedTests = true;
|
|
332
|
+
}
|
|
361
333
|
return;
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
334
|
+
}
|
|
335
|
+
console.log(
|
|
336
|
+
APP_PREFIX,
|
|
337
|
+
chalk.yellow(`Warning: (${err.response?.status})`),
|
|
338
|
+
`Report couldn't be processed: ${err?.response?.data?.message}`,
|
|
339
|
+
);
|
|
340
|
+
printCreateIssue(err);
|
|
341
|
+
} else {
|
|
342
|
+
console.log(APP_PREFIX, "Report couldn't be processed", err);
|
|
370
343
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Adds a test to the batch uploader (or reports a single test if batch uploading is disabled)
|
|
349
|
+
*/
|
|
350
|
+
addTest(data) {
|
|
351
|
+
this.isEnabled = this.apiKey ?? this.isEnabled;
|
|
352
|
+
|
|
353
|
+
if (!this.isEnabled) return;
|
|
354
|
+
if (!this.runId) return;
|
|
355
|
+
|
|
356
|
+
// add test ID + run ID
|
|
357
|
+
if (data.rid) data.rid = `${this.runId}-${data.rid}`;
|
|
358
|
+
data.api_key = this.apiKey;
|
|
359
|
+
data.create = this.createNewTests;
|
|
360
|
+
|
|
361
|
+
let uploading = null;
|
|
362
|
+
if (!this.batch.isEnabled) uploading = this.#uploadSingleTest(data);
|
|
363
|
+
else this.batch.tests.push(data);
|
|
364
|
+
|
|
365
|
+
// if test is added after run already finished
|
|
366
|
+
if (!this.batch.intervalFunction) uploading = this.#batchUpload();
|
|
367
|
+
|
|
368
|
+
// return promise to be able to wait for it
|
|
369
|
+
return uploading;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @param {import('../../types').RunData} params
|
|
374
|
+
* @returns
|
|
375
|
+
*/
|
|
376
|
+
async finishRun(params) {
|
|
377
|
+
if (!this.isEnabled) return;
|
|
378
|
+
|
|
379
|
+
await this.#batchUpload();
|
|
380
|
+
if (this.batch.intervalFunction) {
|
|
381
|
+
clearInterval(this.batch.intervalFunction);
|
|
382
|
+
// this code is required in case test is added after run is finished
|
|
383
|
+
// (e.g. if test has artifacts, add test function will be invoked only after artifacts are uploaded)
|
|
384
|
+
// batch stops working after run is finished; thus, disable it to use single test uploading
|
|
385
|
+
this.batch.intervalFunction = null;
|
|
386
|
+
this.batch.isEnabled = false;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
debug('Finishing run...');
|
|
390
|
+
|
|
391
|
+
if (this.reportingCanceledDueToReqFailures) {
|
|
392
|
+
const errorMessage = chalk.red(
|
|
393
|
+
`⚠️ Due to request failures, ${this.notReportedTestsCount} test(s) were not reported to Testomat.io`,
|
|
394
|
+
);
|
|
395
|
+
console.warn(`${APP_PREFIX} ${errorMessage}`);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
const { status, parallel } = params;
|
|
399
|
+
|
|
400
|
+
let status_event;
|
|
401
|
+
|
|
402
|
+
if (status === STATUS.FINISHED) status_event = 'finish';
|
|
403
|
+
if (status === STATUS.PASSED) status_event = 'pass';
|
|
404
|
+
if (status === STATUS.FAILED) status_event = 'fail';
|
|
405
|
+
if (parallel) status_event += '_parallel';
|
|
406
|
+
|
|
407
|
+
try {
|
|
408
|
+
if (this.runId && !this.proceed) {
|
|
409
|
+
await this.axios.put(`/api/reporter/${this.runId}`, {
|
|
410
|
+
api_key: this.apiKey,
|
|
411
|
+
status_event,
|
|
412
|
+
detach: params.detach,
|
|
413
|
+
duration: params.duration,
|
|
414
|
+
tests: params.tests,
|
|
415
|
+
});
|
|
416
|
+
if (this.runUrl) {
|
|
417
|
+
console.log(APP_PREFIX, '📊 Report Saved. Report URL:', chalk.magenta(this.runUrl));
|
|
422
418
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
printCreateIssue(err);
|
|
419
|
+
if (this.runPublicUrl) {
|
|
420
|
+
console.log(APP_PREFIX, '🌟 Public URL:', chalk.magenta(this.runPublicUrl));
|
|
426
421
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
422
|
+
}
|
|
423
|
+
if (this.runUrl && this.proceed) {
|
|
424
|
+
const notFinishedMessage = chalk.yellow.bold('Run was not finished because of $TESTOMATIO_PROCEED');
|
|
425
|
+
console.log(APP_PREFIX, `📊 ${notFinishedMessage}. Report URL: ${chalk.magenta(this.runUrl)}`);
|
|
426
|
+
console.log(APP_PREFIX, `🛬 Run to finish it: TESTOMATIO_RUN=${this.runId} npx start-test-run --finish`);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if (this.hasUnmatchedTests) {
|
|
430
|
+
console.log('');
|
|
431
|
+
// eslint-disable-next-line max-len
|
|
432
|
+
console.log(APP_PREFIX, chalk.yellow.bold('⚠️ Some reported tests were not found in Testomat.io project'));
|
|
433
|
+
// eslint-disable-next-line max-len
|
|
434
|
+
console.log(
|
|
435
|
+
APP_PREFIX,
|
|
436
|
+
`If you use Testomat.io as a reporter only, please re-run tests using ${chalk.bold('TESTOMATIO_CREATE=1')}`,
|
|
437
|
+
);
|
|
438
|
+
// eslint-disable-next-line max-len
|
|
439
|
+
console.log(
|
|
440
|
+
APP_PREFIX,
|
|
441
|
+
`But to keep your tests consistent it is recommended to ${chalk.bold('import tests first')}`,
|
|
442
|
+
);
|
|
443
|
+
console.log(APP_PREFIX, 'If tests were imported but still not matched, assign test IDs to your tests.');
|
|
444
|
+
console.log(APP_PREFIX, 'You can do that automatically via command line tools:');
|
|
445
|
+
console.log(APP_PREFIX, chalk.bold('npx check-tests ... --update-ids'), 'See: https://bit.ly/js-update-ids');
|
|
446
|
+
console.log(APP_PREFIX, 'or for Cucumber:');
|
|
447
|
+
// eslint-disable-next-line max-len
|
|
448
|
+
console.log(
|
|
449
|
+
APP_PREFIX,
|
|
450
|
+
chalk.bold('npx check-cucumber ... --update-ids'),
|
|
451
|
+
'See: https://bit.ly/bdd-update-ids',
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
} catch (err) {
|
|
455
|
+
console.log(APP_PREFIX, 'Error updating status, skipping...', err);
|
|
456
|
+
printCreateIssue(err);
|
|
431
457
|
}
|
|
458
|
+
debug('Run finished');
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
toString() {
|
|
462
|
+
return 'Testomatio Reporter';
|
|
463
|
+
}
|
|
432
464
|
}
|
|
465
|
+
|
|
433
466
|
let registeredErrorHints = false;
|
|
434
467
|
function printCreateIssue(err) {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
});
|
|
468
|
+
if (registeredErrorHints) return;
|
|
469
|
+
registeredErrorHints = true;
|
|
470
|
+
process.on('exit', () => {
|
|
471
|
+
console.log();
|
|
472
|
+
console.log(APP_PREFIX, 'There was an error reporting to Testomat.io:');
|
|
473
|
+
console.log(
|
|
474
|
+
APP_PREFIX,
|
|
475
|
+
'If you think this is a bug please create an issue: https://github.com/testomatio/reporter/issues/new',
|
|
476
|
+
); // eslint-disable-line max-len
|
|
477
|
+
console.log(APP_PREFIX, 'Provide this information:');
|
|
478
|
+
console.log('Error:', err.message || err.code);
|
|
479
|
+
if (!err.config) return;
|
|
480
|
+
|
|
481
|
+
const time = new Date().toUTCString();
|
|
482
|
+
const { data, url, baseURL, method } = err?.config || {};
|
|
483
|
+
console.log('```js');
|
|
484
|
+
console.log({ data: data?.replace(/"(tstmt_[^"]+)"/g, 'tstmt_*'), url, baseURL, method, time });
|
|
485
|
+
console.log('```');
|
|
486
|
+
});
|
|
452
487
|
}
|
|
488
|
+
|
|
489
|
+
const axiosAddTestrunRequestConfig = {
|
|
490
|
+
maxContentLength: Infinity,
|
|
491
|
+
maxBodyLength: Infinity,
|
|
492
|
+
headers: {
|
|
493
|
+
// Overwrite Axios's automatically set Content-Type
|
|
494
|
+
'Content-Type': 'application/json',
|
|
495
|
+
},
|
|
496
|
+
};
|
|
497
|
+
|
|
453
498
|
module.exports = TestomatioPipe;
|