@testomatio/reporter 0.8.1 → 0.8.2-beta.1

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/Changelog.md ADDED
@@ -0,0 +1,251 @@
1
+ # 0.7.6
2
+
3
+ * Updated to use AWS S3 3.0 SDK for uploading
4
+
5
+ # 0.7.5
6
+
7
+ * Fixed reporting skipped tests in mocha
8
+
9
+ # 0.7.4
10
+
11
+ * Fixed parsing source code in JUnit files
12
+
13
+ # 0.7.3
14
+
15
+ * CodeceptJS: Upload all traces and videos from artifacts
16
+ * Fixed reporting skipped test in XML
17
+ * added `--timelimit` option to `report-xml` command line
18
+
19
+ # 0.7.2
20
+
21
+ * Fixed uploading non-existing file
22
+
23
+ # 0.7.1
24
+
25
+ * Support for NUnit XML v3 format
26
+
27
+ # 0.7.0
28
+
29
+ * Support for `@cucumber/cucumber` (>= 7.0) added
30
+ * Initial support for C# and NUnit
31
+
32
+ # 0.6.10
33
+
34
+ * Fixed uploading multilpe artifacts in Playwright
35
+
36
+ # 0.6.9
37
+
38
+ * Fixed pending tests reports for Cypress
39
+
40
+ # 0.6.8
41
+ # 0.6.7
42
+
43
+ * Pytest: fixed creating suites from reports
44
+
45
+ # 0.6.6
46
+
47
+ * JUnit reporter: prefer suite title over testcase classname in a report
48
+
49
+ # 0.6.5
50
+
51
+ * Fixed test statuses for runs in JUnit reporter
52
+
53
+ # 0.6.4
54
+
55
+ * Added `TESTOMATIO_PROCEED=1` param to not close current run
56
+ * Fixed priority of commands from `npx @testomatio/reporter`
57
+
58
+ # 0.6.3
59
+
60
+ * Fixed `npx start-test-run` to launch commands
61
+
62
+ # 0.6.2
63
+
64
+ * Added `--env-file` option to load env variables from env file
65
+
66
+ # 0.6.1
67
+
68
+ * Fixed creating RunGroup with JUnit reporter
69
+
70
+ # 0.6.0
71
+
72
+ * JUnit reporter support
73
+
74
+ # 0.5.10
75
+
76
+ * Fixed reporting Scenario Outline in Cypress-Cucumber
77
+ * Fixed error reports for Cypress when running in Chrome
78
+
79
+ # 0.5.9
80
+
81
+ * Added environment on Cypress report
82
+
83
+ # 0.5.8
84
+
85
+ * Fixed Cypress.io reporting
86
+
87
+ # 0.5.7
88
+
89
+ * Fixed webdriverio artifacts
90
+
91
+ # 0.5.6
92
+
93
+ * Unmark failed CodeceptJS tests as skipped
94
+
95
+ # 0.5.5
96
+
97
+ * Fixed `BeforeSuite` failures in CodeceptJS
98
+
99
+ # 0.5.4
100
+
101
+ Added `TESTOMATIO_CREATE=1` option to create unmatched tests on report
102
+
103
+ ```
104
+ TESTOMATIO_CREATE=1 TESTOMATIO=apiKey npx codeceptjs run
105
+ ```
106
+
107
+ # 0.5.3
108
+
109
+ * Fixed parsing suites
110
+
111
+ # 0.5.2
112
+
113
+ * Fixed multiple upload of artifacts in Cypress.io
114
+
115
+ # 0.5.1
116
+
117
+ * Fixed Cypress.io to report tests inside nested suites
118
+
119
+ # 0.5.0
120
+
121
+ * Added Cypress.io plugin
122
+ * Added artifacts upload to webdriverio
123
+
124
+ # 0.4.6
125
+
126
+ - Fixed CodeceptJS reporter to report tests failed in hooks
127
+
128
+ # 0.4.5
129
+
130
+ - Fixed "Total XX artifacts publicly uploaded to S3 bucket" when no S3 bucket is configured
131
+ - Improved S3 connection error messages
132
+
133
+ # 0.4.4
134
+
135
+ - 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.
136
+
137
+ # 0.4.3
138
+
139
+ - Added `TESTOMATIO_DISABLE_ARTIFACTS` env variable to disable publishing artifacts.
140
+
141
+ # 0.4.2
142
+
143
+ - print version of reporter
144
+ - print number of uploaded artifacts
145
+ - print access mode for uploaded artifacts
146
+
147
+ # 0.4.1
148
+
149
+ Added `global.testomatioArtifacts = []` array which can be used to add arbitrary artifacts to a report.
150
+
151
+ ```js
152
+ // inside a running test:
153
+ global.testomatioArtifacts.push('file/to/upload.png');
154
+ ```
155
+
156
+ # 0.4.0
157
+
158
+ - Playwright: Introduced playwright/test support with screenshots and video artifacts
159
+
160
+ > Known issues: reporting using projects configured in Playwright does not work yet
161
+
162
+ - CodeceptJS: added video uploads
163
+
164
+ # 0.3.16
165
+
166
+ - CodeceptJS: fixed reporting tests with empty steps (on retry)
167
+
168
+ # 0.3.15
169
+
170
+ - Finish Run via API:
171
+
172
+ ```
173
+ TESTOMATIO={apiKey} TESTOMATIO_RUN={runId} npx @testomatio/reporter@latest --finish
174
+ ```
175
+
176
+ # 0.3.14
177
+
178
+ - Create an empty Run via API:
179
+
180
+ ```
181
+ TESTOMATIO={apiKey} npx @testomatio/reporter@latest --launch
182
+ ```
183
+
184
+ # 0.3.13
185
+
186
+ - Checking for a valid report URL
187
+ - Sending unlimited data on test report
188
+
189
+ # 0.3.12
190
+
191
+ - Fixed submitting arbitrary data on a test run
192
+ - Jest: fixed sending errors with stack traces
193
+ - Cypress: fixed sending reports
194
+
195
+ # 0.3.11
196
+
197
+ - Fixed circular JSON reference when submitting data to Testomatio
198
+
199
+ # 0.3.10
200
+
201
+ - Minor fixes
202
+
203
+ # 0.3.9
204
+
205
+ - Making all reporters to run without API key
206
+
207
+ # 0.3.8
208
+
209
+ - Fixed `npx start-test-run` to work with empty API keys
210
+
211
+ # 0.3.7
212
+
213
+ - Fixed release
214
+
215
+ # 0.3.6
216
+
217
+ - Update title and rungroup on start for scheduled runs.
218
+
219
+ # 0.3.5
220
+
221
+ - Added `TESTOMATIO_RUN` environment variable to pass id of a specific run to report
222
+
223
+ # 0.3.4
224
+
225
+ - Minor fixes
226
+
227
+ # 0.3.3
228
+
229
+ - [CodeceptJS] Fixed stack trace reporting
230
+ - [CodeceptJS] Fixed displaying of nested steps
231
+ - [CodeceptJS][mocha] Added assertion diff to report
232
+
233
+ # 0.3.2
234
+
235
+ - Fixed error message for S3 uploading
236
+
237
+ # 0.3.1
238
+
239
+ - [CodeceptJS] Better formatter for nested structures and BDD tests
240
+
241
+ # 0.3.0
242
+
243
+ - Added `TESTOMATIO_TITLE` env variable to set a name for Run
244
+ - Added `TESTOMATIO_RUNGROUP_TITLE` env variable to attach Run to RunGroup
245
+ - Added `TESTOMATIO_ENV` env variable to attach additional env values to report
246
+ - [CodeceptJS] **CodeceptJS v3 support**
247
+ - [CodeceptJS] Dropped support for CodeceptJS 2
248
+ - [CodeceptJS] Added support for before hooks
249
+ - [CodeceptJS] Log of steps
250
+ - [CodeceptJS] Upload screenshots of failed tests to S3
251
+ - [CodeceptJS] Updated to use with parallel execution
@@ -5,7 +5,7 @@ const path = require('path');
5
5
  const fs = require('fs');
6
6
  const { APP_PREFIX, STATUS: Status } = require('../constants');
7
7
  const TestomatioClient = require('../client');
8
- const upload = require('../fileUploader');
8
+ const { isArtifactsEnabled } = require('../fileUploader');
9
9
  const { parseTest } = require('../util');
10
10
 
11
11
 
@@ -13,7 +13,7 @@ class TestomatioReporter {
13
13
  constructor(config = {}) {
14
14
  this.client = new TestomatioClient({ apiKey: config?.apiKey });
15
15
 
16
- this.videos = [];
16
+ this.uploads = [];
17
17
  }
18
18
 
19
19
  onBegin(_config, suite) {
@@ -37,32 +37,15 @@ class TestomatioReporter {
37
37
  appendStep(step, steps);
38
38
  }
39
39
 
40
- const files = [];
41
-
42
- for (const attachment of result.attachments) {
43
- if (!attachment.body && !attachment.path) {
44
- continue;
45
- }
46
- if (attachment.contentType && attachment.contentType.startsWith('video')) {
47
- // video is post-processed
48
- this.videos.push({ testId, attachment, title, suite_title });
49
- continue;
50
- }
51
-
52
- let fileName = attachment.path;
53
- if (attachment.body) {
54
- fileName = tmpFile();
55
- fs.writeFileSync(fileName, attachment.body);
56
- }
57
- files.push({ path: fileName, type: attachment.contentType });
58
- }
40
+ this.uploads.push({
41
+ testId, title, suite_title, files: result.attachments.filter((a) => a.body || a.path)
42
+ })
59
43
 
60
44
  this.client.addTestRun(checkStatus(result.status), {
61
45
  error,
62
46
  test_id: testId,
63
47
  suite_title,
64
48
  title,
65
- files,
66
49
  steps: steps.join('\n'),
67
50
  time: duration,
68
51
  });
@@ -71,19 +54,30 @@ class TestomatioReporter {
71
54
  async onEnd(result) {
72
55
  if (!this.client) return;
73
56
 
74
- if (this.videos.length && upload.isArtifactsEnabled()) {
75
- console.log(APP_PREFIX, `🎞️ Uploading ${this.videos.length} videos...`);
57
+ if (this.uploads.length && isArtifactsEnabled()) {
58
+ console.log(APP_PREFIX, `🎞️ Uploading ${this.uploads.length} files...`);
76
59
 
77
60
  const promises = [];
78
- for (const video of this.videos) {
79
- const { testId, title, attachment, suite_title } = video;
80
- const file = { path: attachment.path, title, type: attachment.contentType };
61
+
62
+ for (const upload of this.uploads) {
63
+
64
+ const { title, testId, suite_title } = upload;
65
+
66
+ const files = upload.files.map((attachment) => {
67
+ if (attachment.body) {
68
+ const fileName = tmpFile();
69
+ fs.writeFileSync(fileName, attachment.body);
70
+ }
71
+ return { path: attachment.path, title, type: attachment.contentType };
72
+ });
73
+
74
+
81
75
  promises.push(
82
76
  this.client.addTestRun(undefined, {
83
77
  test_id: testId,
84
78
  title,
85
79
  suite_title,
86
- files: [file],
80
+ files,
87
81
  }),
88
82
  );
89
83
  }
@@ -1,6 +1,7 @@
1
1
  const debug = require('debug')('@testomatio/reporter:file-uploader');
2
2
  const { S3 } = require('@aws-sdk/client-s3');
3
3
  const { Upload } = require('@aws-sdk/lib-storage');
4
+
4
5
  const fs = require('fs');
5
6
  const path = require('path');
6
7
  const chalk = require('chalk');
@@ -27,10 +28,14 @@ function getConfig() {
27
28
  acc[key] = process.env[key];
28
29
  return acc;
29
30
  }, {});
30
- debug('Config', config);
31
31
  return config;
32
32
  }
33
33
 
34
+ function getMaskedConfig() {
35
+ const config = getConfig();
36
+ return Object.fromEntries(Object.entries(config).map(([key, value]) => [key, key === 'S3_SECRET_ACCESS_KEY' || key === 'S3_ACCESS_KEY_ID' ? '***' : value]));
37
+ }
38
+
34
39
  let isEnabled;
35
40
 
36
41
  const isArtifactsEnabled = () => {
@@ -89,27 +94,30 @@ const uploadUsingS3 = async (filePath, runId) => {
89
94
  }
90
95
 
91
96
  const {
92
- S3_REGION, S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_ENDPOINT, TESTOMATIO_PRIVATE_ARTIFACTS, S3_BUCKET
97
+ TESTOMATIO_PRIVATE_ARTIFACTS, S3_BUCKET
93
98
  } = getConfig();
99
+
100
+ debug('S3 config', getMaskedConfig());
101
+ debug('Uploading', filePath, 'to', S3_BUCKET);
94
102
 
95
- const file = fs.readFileSync(filePath);
103
+ const fileData = fs.readFileSync(filePath);
96
104
 
97
105
  Key = `${runId}/${randomUUID()}-${Key || path.basename(filePath)}`;
98
106
  const ACL = TESTOMATIO_PRIVATE_ARTIFACTS ? 'private' : 'public-read';
99
107
 
100
108
  const s3 = new S3(_getS3Config());
101
109
 
110
+ const params = {
111
+ Bucket: S3_BUCKET,
112
+ Key,
113
+ Body: fileData,
114
+ ACL,
115
+ };
116
+
102
117
  try {
103
118
  const out = new Upload({
104
119
  client: s3,
105
-
106
- params: {
107
- Bucket: S3_BUCKET,
108
- Key,
109
- Body: file,
110
- ContentType,
111
- ACL,
112
- }
120
+ params
113
121
  });
114
122
 
115
123
  await out.done();
@@ -117,14 +125,8 @@ const uploadUsingS3 = async (filePath, runId) => {
117
125
 
118
126
  return out.singleUploadResult.Location;
119
127
  } catch (e) {
120
- console.log(APP_PREFIX, chalk.bold.red(`Failed uploading '${Key}'. Please check S3 credentials`), {
121
- accessKeyId: S3_ACCESS_KEY_ID,
122
- secretAccessKey: S3_SECRET_ACCESS_KEY ? '**** (hidden) ***' : '(empty)',
123
- region: S3_REGION,
124
- bucket: S3_BUCKET,
125
- acl: ACL,
126
- endpoint: S3_ENDPOINT,
127
- });
128
+ console.log(e);
129
+ console.log(APP_PREFIX, chalk.bold.red(`Failed uploading '${Key}'. Please check S3 credentials`), getMaskedConfig());
128
130
 
129
131
  console.log(APP_PREFIX, `To ${chalk.bold('disable')} artifact uploads set: TESTOMATIO_DISABLE_ARTIFACTS=1`);
130
132
  if (!TESTOMATIO_PRIVATE_ARTIFACTS) {
@@ -136,7 +138,7 @@ const uploadUsingS3 = async (filePath, runId) => {
136
138
  );
137
139
  }
138
140
  console.log(APP_PREFIX, '---------------');
139
- }
141
+ }
140
142
  };
141
143
 
142
144
  const uploadUsingS3AsBuffer = async (buffer, fileName, runId) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "0.8.1",
3
+ "version": "0.8.2-beta.1",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "main": "./lib/reporter.js",
6
6
  "typings": "typings/index.d.ts",