@testomatio/reporter 1.0.13 → 1.0.15-beta

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/client.js CHANGED
@@ -36,6 +36,7 @@ class Client {
36
36
  * @returns {Promise<any>} - resolves to Run id which should be used to update / add test
37
37
  */
38
38
  createRun() {
39
+ debug('Creating run...');
39
40
  // all pipes disabled, skipping
40
41
  if (!this.pipes?.filter(p => p.isEnabled).length) return Promise.resolve();
41
42
 
@@ -59,6 +60,7 @@ class Client {
59
60
  * @returns {Promise<PipeResult[]>}
60
61
  */
61
62
  async addTestRun(status, testData, storeArtifacts = []) {
63
+ debug('Adding test run for test', testData?.test_id || 'unknown test');
62
64
  // all pipes disabled, skipping
63
65
  if (!this.pipes?.filter(p => p.isEnabled).length) return [];
64
66
 
@@ -170,6 +172,7 @@ class Client {
170
172
  * @returns {Promise<any>} - A Promise that resolves when finishes the run.
171
173
  */
172
174
  updateRunStatus(status, isParallel = false) {
175
+ debug('Updating run status...');
173
176
  // all pipes disabled, skipping
174
177
  if (!this.pipes?.filter(p => p.isEnabled).length) return Promise.resolve();
175
178
 
@@ -33,7 +33,9 @@ class TestomatioPipe {
33
33
  this.sharedRun = !!process.env.TESTOMATIO_SHARED_RUN;
34
34
  this.groupTitle = params.groupTitle || process.env.TESTOMATIO_RUNGROUP_TITLE;
35
35
  this.env = process.env.TESTOMATIO_ENV;
36
- this.axios = axios.create();
36
+ this.axios = axios.create({
37
+ timeout: 30000,
38
+ });
37
39
  this.isEnabled = true;
38
40
  // do not finish this run (for parallel testing)
39
41
  this.proceed = process.env.TESTOMATIO_PROCEED;
@@ -51,6 +53,7 @@ class TestomatioPipe {
51
53
  * @returns Promise<void>
52
54
  */
53
55
  async createRun() {
56
+ debug('Creating run...');
54
57
  if (!this.isEnabled) return;
55
58
 
56
59
  let buildUrl = process.env.BUILD_URL || process.env.CI_JOB_URL || process.env.CIRCLE_BUILD_URL;
@@ -58,7 +61,7 @@ class TestomatioPipe {
58
61
  // GitHub Actions Url
59
62
  if (!buildUrl && process.env.GITHUB_RUN_ID) {
60
63
  // eslint-disable-next-line max-len
61
- buildUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`
64
+ buildUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`;
62
65
  }
63
66
 
64
67
  // Azure DevOps Url
@@ -83,10 +86,12 @@ class TestomatioPipe {
83
86
  env: this.env,
84
87
  title: this.title,
85
88
  shared_run: this.sharedRun,
86
- }).filter(([, value]) => !!value)
89
+ }).filter(([, value]) => !!value),
87
90
  );
91
+ debug('Run params', JSON.stringify(runParams, null, 2));
88
92
 
89
93
  if (this.runId) {
94
+ debug(`Run with id ${this.runId} already created, updating...`);
90
95
  const resp = await this.axios.put(`${this.url.trim()}/api/reporter/${this.runId}`, runParams);
91
96
  if (resp.data.artifacts) setS3Credentials(resp.data.artifacts);
92
97
  return;
@@ -106,61 +111,70 @@ class TestomatioPipe {
106
111
  this.store.runId = this.runId;
107
112
  console.log(APP_PREFIX, '📊 Report created. Report ID:', this.runId);
108
113
  process.env.runId = this.runId;
114
+ debug('Run created', this.runId);
109
115
  } catch (err) {
110
116
  console.error(
111
117
  APP_PREFIX,
112
118
  'Error creating Testomat.io report, please check if your API key is valid. Skipping report',
119
+ err,
113
120
  );
114
121
  }
122
+ debug('"createRun" function finished');
115
123
  }
116
124
 
117
125
  /**
118
- *
119
- * @param testData data
120
- * @returns
126
+ *
127
+ * @param testData data
128
+ * @returns
121
129
  */
122
130
  addTest(data) {
131
+ debug('Adding test...');
123
132
  if (!this.isEnabled) return;
124
133
  if (!this.runId) return;
125
134
  data.api_key = this.apiKey;
126
135
  data.create = this.createNewTests;
127
136
  const json = JsonCycle.stringify(data);
128
137
 
129
- return this.axios.post(`${this.url}/api/reporter/${this.runId}/testrun`, json, {
130
- maxContentLength: Infinity,
131
- maxBodyLength: Infinity,
132
- headers: {
133
- // Overwrite Axios's automatically set Content-Type
134
- 'Content-Type': 'application/json',
135
- },
136
- })
137
- .catch((err) => {
138
- if (err.response) {
139
- if (err.response.status >= 400) {
140
- const responseData = err.response.data || { message: '' };
138
+ return this.axios
139
+ .post(`${this.url}/api/reporter/${this.runId}/testrun`, json, {
140
+ maxContentLength: Infinity,
141
+ maxBodyLength: Infinity,
142
+ headers: {
143
+ // Overwrite Axios's automatically set Content-Type
144
+ 'Content-Type': 'application/json',
145
+ },
146
+ })
147
+ .catch(err => {
148
+ if (err.response) {
149
+ if (err.response.status >= 400) {
150
+ const responseData = err.response.data || { message: '' };
151
+ console.log(
152
+ APP_PREFIX,
153
+ chalk.yellow(`Warning: ${responseData.message} (${err.response.status})`),
154
+ chalk.grey(data?.title || ''),
155
+ );
156
+ if (err.response.data.message.includes('could not be matched')) {
157
+ this.hasUnmatchedTests = true;
158
+ }
159
+ return;
160
+ }
141
161
  console.log(
142
162
  APP_PREFIX,
143
- chalk.yellow(`Warning: ${responseData.message} (${err.response.status})`),
144
- chalk.grey(data?.title || ''),
163
+ chalk.yellow(`Warning: ${data?.title || ''} (${err.response?.status})`),
164
+ `Report couldn't be processed: ${err?.response?.data?.message}`,
145
165
  );
146
- if (err.response.data.message.includes('could not be matched')) {
147
- this.hasUnmatchedTests = true;
148
- }
149
- return;
166
+ } else {
167
+ console.log(APP_PREFIX, chalk.blue(data?.title || ''), "Report couldn't be processed", err);
150
168
  }
151
- // eslint-disable-next-line max-len
152
- console.log(APP_PREFIX, chalk.blue(data?.title || ''), `Report couldn't be processed: ${err.response.data.message}`);
153
- } else {
154
- console.log(APP_PREFIX, chalk.blue(data?.title || ''), "Report couldn't be processed", err);
155
- }
156
- });
169
+ });
157
170
  }
158
171
 
159
172
  /**
160
- * @param {import('../../types').RunData} params
161
- * @returns
173
+ * @param {import('../../types').RunData} params
174
+ * @returns
162
175
  */
163
176
  async finishRun(params) {
177
+ debug('Finishing run...');
164
178
  if (!this.isEnabled) return;
165
179
 
166
180
  const { status, parallel } = params;
@@ -185,7 +199,6 @@ class TestomatioPipe {
185
199
  if (this.runPublicUrl) {
186
200
  console.log(APP_PREFIX, '🌟 Public URL:', chalk.magenta(this.runPublicUrl));
187
201
  }
188
-
189
202
  }
190
203
  if (this.runUrl && this.proceed) {
191
204
  const notFinishedMessage = chalk.yellow.bold('Run was not finished because of $TESTOMATIO_PROCEED');
@@ -197,19 +210,30 @@ class TestomatioPipe {
197
210
  // eslint-disable-next-line max-len
198
211
  console.log(APP_PREFIX, chalk.yellow.bold('⚠️ Some reported tests were not found in Testomat.io project'));
199
212
  // eslint-disable-next-line max-len
200
- console.log(APP_PREFIX, `If you use Testomat.io as a reporter only, please re-run tests using ${chalk.bold('TESTOMATIO_CREATE=1')}`);
213
+ console.log(
214
+ APP_PREFIX,
215
+ `If you use Testomat.io as a reporter only, please re-run tests using ${chalk.bold('TESTOMATIO_CREATE=1')}`,
216
+ );
201
217
  // eslint-disable-next-line max-len
202
- console.log(APP_PREFIX, `But to keep your tests consistent it is recommended to ${chalk.bold('import tests first')}`);
218
+ console.log(
219
+ APP_PREFIX,
220
+ `But to keep your tests consistent it is recommended to ${chalk.bold('import tests first')}`,
221
+ );
203
222
  console.log(APP_PREFIX, 'If tests were imported but still not matched, assign test IDs to your tests.');
204
223
  console.log(APP_PREFIX, 'You can do that automatically via command line tools:');
205
224
  console.log(APP_PREFIX, chalk.bold('npx check-tests ... --update-ids'), 'See: https://bit.ly/js-update-ids');
206
225
  console.log(APP_PREFIX, 'or for Cucumber:');
207
226
  // eslint-disable-next-line max-len
208
- console.log(APP_PREFIX, chalk.bold('npx check-cucumber ... --update-ids'), 'See: https://bit.ly/bdd-update-ids');
227
+ console.log(
228
+ APP_PREFIX,
229
+ chalk.bold('npx check-cucumber ... --update-ids'),
230
+ 'See: https://bit.ly/bdd-update-ids',
231
+ );
209
232
  }
210
233
  } catch (err) {
211
234
  console.log(APP_PREFIX, 'Error updating status, skipping...', err);
212
235
  }
236
+ debug('Run finished');
213
237
  }
214
238
 
215
239
  toString() {
@@ -219,17 +243,16 @@ class TestomatioPipe {
219
243
 
220
244
  module.exports = TestomatioPipe;
221
245
 
222
-
223
- function setS3Credentials(artifacts) {
246
+ function setS3Credentials(artifacts) {
224
247
  if (!Object.keys(artifacts).length) return;
225
248
 
226
249
  console.log(APP_PREFIX, 'S3 were credentials obtained from Testomat.io...');
227
250
 
228
- if (artifacts.ACCESS_KEY_ID) process.env.S3_ACCESS_KEY_ID = artifacts.ACCESS_KEY_ID;
229
- if (artifacts.SECRET_ACCESS_KEY) process.env.S3_SECRET_ACCESS_KEY = artifacts.SECRET_ACCESS_KEY;
230
- if (artifacts.REGION) process.env.S3_REGION = artifacts.REGION;
231
- if (artifacts.BUCKET) process.env.S3_BUCKET = artifacts.BUCKET;
232
- if (artifacts.ENDPOINT) process.env.S3_ENDPOINT = artifacts.ENDPOINT;
233
- if (artifacts.presign) process.env.TESTOMATIO_PRIVATE_ARTIFACTS = '1';
251
+ if (artifacts.ACCESS_KEY_ID) process.env.S3_ACCESS_KEY_ID = artifacts.ACCESS_KEY_ID;
252
+ if (artifacts.SECRET_ACCESS_KEY) process.env.S3_SECRET_ACCESS_KEY = artifacts.SECRET_ACCESS_KEY;
253
+ if (artifacts.REGION) process.env.S3_REGION = artifacts.REGION;
254
+ if (artifacts.BUCKET) process.env.S3_BUCKET = artifacts.BUCKET;
255
+ if (artifacts.ENDPOINT) process.env.S3_ENDPOINT = artifacts.ENDPOINT;
256
+ if (artifacts.presign) process.env.TESTOMATIO_PRIVATE_ARTIFACTS = '1';
234
257
  resetConfig();
235
258
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "1.0.13",
3
+ "version": "1.0.15-beta",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "main": "./lib/reporter.js",
6
6
  "typings": "typings/index.d.ts",
package/Changelog.md DELETED
@@ -1,322 +0,0 @@
1
- <!-- pending release updates -->
2
- # 1.0.13
3
-
4
- * JUnit improvements
5
- * Match test from source code by adding Test ID as a comment:
6
-
7
- ```java
8
- // @T8acca9eb
9
- ```
10
- * Match test from output by adding Test ID as output:
11
-
12
- ```java
13
- System.out.println("tid://@T8acca9eb");
14
- ```
15
- * Support for suite before and after output
16
- * Improved support for artifacts
17
-
18
- # 1.0.12
19
-
20
- & Logger refactoring by @olexandr13 in #208
21
- * fix undefined logs by @olexandr13 in #210
22
-
23
- # 1.0.11
24
-
25
- * fix steps duplication for codecept report by @olexandr13 in #209
26
-
27
- # 1.0.10
28
-
29
- * Added `TESTOMATIO_PUBLISH=1` variable to automatically publish run report
30
-
31
- # 1.0.9
32
-
33
- * Support XUnit format
34
- * Improved support for parametrized Java tests
35
-
36
- # 1.0.8
37
-
38
- * Fixed `Can't read push of undefined` when logging steps
39
-
40
- # 1.0.6
41
-
42
- * Testomat.io. Auto-detect current build url and report it to Testomat.io. Manually url can be set with `BUILD_URL` variable:
43
-
44
- ```
45
- BUILD_URL=https://.... TESTOMATIO=apiKey <actual test command>
46
- ```
47
-
48
- # 1.0.5
49
-
50
- * Fix "create tests" params processing for testomatio pipe
51
-
52
- # 1.0.4
53
-
54
- * Fixed parallel run
55
-
56
- # 1.0.3
57
-
58
- * Fixed reporting parallel runs
59
-
60
- # 1.0.0
61
-
62
-
63
- * Added [`TESTOMATIO_SHARED_RUN` option](https://github.com/testomatio/reporter/blob/master/docs/pipes.md#reporting-parallel-execution-to-to-same-run) to use a shared run for parallel executions
64
- * Reworked [documentation](https://github.com/testomatio/reporter/tree/master#readme).
65
- * Added an option to obtain [S3 configuration](https://github.com/testomatio/reporter/blob/master/docs/artifacts.md#configuration) from Testomat.io
66
- * Introduced [pipes](https://github.com/testomatio/reporter/blob/master/docs/pipes.md):
67
- * GitHub
68
- * GitLab
69
- * CSV Pipe
70
-
71
-
72
- # 0.7.6
73
-
74
- * Updated to use AWS S3 3.0 SDK for uploading
75
-
76
- # 0.7.5
77
-
78
- * Fixed reporting skipped tests in mocha
79
-
80
- # 0.7.4
81
-
82
- * Fixed parsing source code in JUnit files
83
-
84
- # 0.7.3
85
-
86
- * CodeceptJS: Upload all traces and videos from artifacts
87
- * Fixed reporting skipped test in XML
88
- * added `--timelimit` option to `report-xml` command line
89
-
90
- # 0.7.2
91
-
92
- * Fixed uploading non-existing file
93
-
94
- # 0.7.1
95
-
96
- * Support for NUnit XML v3 format
97
-
98
- # 0.7.0
99
-
100
- * Support for `@cucumber/cucumber` (>= 7.0) added
101
- * Initial support for C# and NUnit
102
-
103
- # 0.6.10
104
-
105
- * Fixed uploading multilpe artifacts in Playwright
106
-
107
- # 0.6.9
108
-
109
- * Fixed pending tests reports for Cypress
110
-
111
- # 0.6.8
112
- # 0.6.7
113
-
114
- * Pytest: fixed creating suites from reports
115
-
116
- # 0.6.6
117
-
118
- * JUnit reporter: prefer suite title over testcase classname in a report
119
-
120
- # 0.6.5
121
-
122
- * Fixed test statuses for runs in JUnit reporter
123
-
124
- # 0.6.4
125
-
126
- * Added `TESTOMATIO_PROCEED=1` param to not close current run
127
- * Fixed priority of commands from `npx @testomatio/reporter`
128
-
129
- # 0.6.3
130
-
131
- * Fixed `npx start-test-run` to launch commands
132
-
133
- # 0.6.2
134
-
135
- * Added `--env-file` option to load env variables from env file
136
-
137
- # 0.6.1
138
-
139
- * Fixed creating RunGroup with JUnit reporter
140
-
141
- # 0.6.0
142
-
143
- * JUnit reporter support
144
-
145
- # 0.5.10
146
-
147
- * Fixed reporting Scenario Outline in Cypress-Cucumber
148
- * Fixed error reports for Cypress when running in Chrome
149
-
150
- # 0.5.9
151
-
152
- * Added environment on Cypress report
153
-
154
- # 0.5.8
155
-
156
- * Fixed Cypress.io reporting
157
-
158
- # 0.5.7
159
-
160
- * Fixed webdriverio artifacts
161
-
162
- # 0.5.6
163
-
164
- * Unmark failed CodeceptJS tests as skipped
165
-
166
- # 0.5.5
167
-
168
- * Fixed `BeforeSuite` failures in CodeceptJS
169
-
170
- # 0.5.4
171
-
172
- Added `TESTOMATIO_CREATE=1` option to create unmatched tests on report
173
-
174
- ```
175
- TESTOMATIO_CREATE=1 TESTOMATIO=apiKey npx codeceptjs run
176
- ```
177
-
178
- # 0.5.3
179
-
180
- * Fixed parsing suites
181
-
182
- # 0.5.2
183
-
184
- * Fixed multiple upload of artifacts in Cypress.io
185
-
186
- # 0.5.1
187
-
188
- * Fixed Cypress.io to report tests inside nested suites
189
-
190
- # 0.5.0
191
-
192
- * Added Cypress.io plugin
193
- * Added artifacts upload to webdriverio
194
-
195
- # 0.4.6
196
-
197
- - Fixed CodeceptJS reporter to report tests failed in hooks
198
-
199
- # 0.4.5
200
-
201
- - Fixed "Total XX artifacts publicly uploaded to S3 bucket" when no S3 bucket is configured
202
- - Improved S3 connection error messages
203
-
204
- # 0.4.4
205
-
206
- - Fixed returning 0 exit code when a process fails when running tests in parallel via `start-test-run`. Previously was using the last exit code returned by a process. Currently prefers the highest exit code that was returned by a process.
207
-
208
- # 0.4.3
209
-
210
- - Added `TESTOMATIO_DISABLE_ARTIFACTS` env variable to disable publishing artifacts.
211
-
212
- # 0.4.2
213
-
214
- - print version of reporter
215
- - print number of uploaded artifacts
216
- - print access mode for uploaded artifacts
217
-
218
- # 0.4.1
219
-
220
- Added `global.testomatioArtifacts = []` array which can be used to add arbitrary artifacts to a report.
221
-
222
- ```js
223
- // inside a running test:
224
- global.testomatioArtifacts.push('file/to/upload.png');
225
- ```
226
-
227
- # 0.4.0
228
-
229
- - Playwright: Introduced playwright/test support with screenshots and video artifacts
230
-
231
- > Known issues: reporting using projects configured in Playwright does not work yet
232
-
233
- - CodeceptJS: added video uploads
234
-
235
- # 0.3.16
236
-
237
- - CodeceptJS: fixed reporting tests with empty steps (on retry)
238
-
239
- # 0.3.15
240
-
241
- - Finish Run via API:
242
-
243
- ```
244
- TESTOMATIO={apiKey} TESTOMATIO_RUN={runId} npx @testomatio/reporter@latest --finish
245
- ```
246
-
247
- # 0.3.14
248
-
249
- - Create an empty Run via API:
250
-
251
- ```
252
- TESTOMATIO={apiKey} npx @testomatio/reporter@latest --launch
253
- ```
254
-
255
- # 0.3.13
256
-
257
- - Checking for a valid report URL
258
- - Sending unlimited data on test report
259
-
260
- # 0.3.12
261
-
262
- - Fixed submitting arbitrary data on a test run
263
- - Jest: fixed sending errors with stack traces
264
- - Cypress: fixed sending reports
265
-
266
- # 0.3.11
267
-
268
- - Fixed circular JSON reference when submitting data to Testomatio
269
-
270
- # 0.3.10
271
-
272
- - Minor fixes
273
-
274
- # 0.3.9
275
-
276
- - Making all reporters to run without API key
277
-
278
- # 0.3.8
279
-
280
- - Fixed `npx start-test-run` to work with empty API keys
281
-
282
- # 0.3.7
283
-
284
- - Fixed release
285
-
286
- # 0.3.6
287
-
288
- - Update title and rungroup on start for scheduled runs.
289
-
290
- # 0.3.5
291
-
292
- - Added `TESTOMATIO_RUN` environment variable to pass id of a specific run to report
293
-
294
- # 0.3.4
295
-
296
- - Minor fixes
297
-
298
- # 0.3.3
299
-
300
- - [CodeceptJS] Fixed stack trace reporting
301
- - [CodeceptJS] Fixed displaying of nested steps
302
- - [CodeceptJS][mocha] Added assertion diff to report
303
-
304
- # 0.3.2
305
-
306
- - Fixed error message for S3 uploading
307
-
308
- # 0.3.1
309
-
310
- - [CodeceptJS] Better formatter for nested structures and BDD tests
311
-
312
- # 0.3.0
313
-
314
- - Added `TESTOMATIO_TITLE` env variable to set a name for Run
315
- - Added `TESTOMATIO_RUNGROUP_TITLE` env variable to attach Run to RunGroup
316
- - Added `TESTOMATIO_ENV` env variable to attach additional env values to report
317
- - [CodeceptJS] **CodeceptJS v3 support**
318
- - [CodeceptJS] Dropped support for CodeceptJS 2
319
- - [CodeceptJS] Added support for before hooks
320
- - [CodeceptJS] Log of steps
321
- - [CodeceptJS] Upload screenshots of failed tests to S3
322
- - [CodeceptJS] Updated to use with parallel execution