@testomatio/reporter 1.1.0-beta-2 → 1.1.0-beta.codeceptjs-before-suite-logs

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,359 @@
1
+ <!-- pending release updates -->
2
+ # 1.0.18
3
+
4
+ * Fixed stack traces for CodeceptJS
5
+
6
+ # 1.0.17
7
+
8
+ Renamed `TESTOMATIO_STACK_FILTER` to `TESTOMATIO_STACK_IGNORE`
9
+
10
+ # 1.0.16
11
+
12
+ * Addded [stack trace configuration](./docs/stacktrace.md) and documentation:
13
+
14
+ ```
15
+ TESTOMATIO_STACK_IGNORE="tests/support/**.js" <actual-run-command>
16
+ ```
17
+ * Jest: fixed reporting tests without a suite title
18
+
19
+ # 1.0.15
20
+
21
+ * Attach Run to Jira Issue via `TESTOMATIO_JIRA_ID` env variable:
22
+
23
+ ```
24
+ TESTOMATIO_JIRA_ID=TST-12 <actual run command>
25
+ ```
26
+
27
+ * Mocha - removed requirement of TESTOMATIO API Key
28
+
29
+ # 1.0.14
30
+
31
+ * Execute tests by tag names. Use this filter to select tests associated with specific tags.
32
+
33
+ ```bash
34
+ TESTOMATIO={API_KEY} npx start-test-run -c 'actual run command' --filter 'testomatio:tag-name=smoke'
35
+ ```
36
+
37
+ * more instruction you can find in docs/pipes/testomatio.md
38
+
39
+ # 1.0.13
40
+
41
+ * JUnit improvements
42
+ * Match test from source code by adding Test ID as a comment:
43
+
44
+ ```java
45
+ // @T8acca9eb
46
+ ```
47
+ * Match test from output by adding Test ID as output:
48
+
49
+ ```java
50
+ System.out.println("tid://@T8acca9eb");
51
+ ```
52
+ * Support for suite before and after output
53
+ * Improved support for artifacts
54
+
55
+ # 1.0.12
56
+
57
+ & Logger refactoring by @olexandr13 in #208
58
+ * fix undefined logs by @olexandr13 in #210
59
+
60
+ # 1.0.11
61
+
62
+ * fix steps duplication for codecept report by @olexandr13 in #209
63
+
64
+ # 1.0.10
65
+
66
+ * Added `TESTOMATIO_PUBLISH=1` variable to automatically publish run report
67
+
68
+ # 1.0.9
69
+
70
+ * Support XUnit format
71
+ * Improved support for parametrized Java tests
72
+
73
+ # 1.0.8
74
+
75
+ * Fixed `Can't read push of undefined` when logging steps
76
+
77
+ # 1.0.6
78
+
79
+ * Testomat.io. Auto-detect current build url and report it to Testomat.io. Manually url can be set with `BUILD_URL` variable:
80
+
81
+ ```
82
+ BUILD_URL=https://.... TESTOMATIO=apiKey <actual test command>
83
+ ```
84
+
85
+ # 1.0.5
86
+
87
+ * Fix "create tests" params processing for testomatio pipe
88
+
89
+ # 1.0.4
90
+
91
+ * Fixed parallel run
92
+
93
+ # 1.0.3
94
+
95
+ * Fixed reporting parallel runs
96
+
97
+ # 1.0.0
98
+
99
+
100
+ * 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
101
+ * Reworked [documentation](https://github.com/testomatio/reporter/tree/master#readme).
102
+ * Added an option to obtain [S3 configuration](https://github.com/testomatio/reporter/blob/master/docs/artifacts.md#configuration) from Testomat.io
103
+ * Introduced [pipes](https://github.com/testomatio/reporter/blob/master/docs/pipes.md):
104
+ * GitHub
105
+ * GitLab
106
+ * CSV Pipe
107
+
108
+
109
+ # 0.7.6
110
+
111
+ * Updated to use AWS S3 3.0 SDK for uploading
112
+
113
+ # 0.7.5
114
+
115
+ * Fixed reporting skipped tests in mocha
116
+
117
+ # 0.7.4
118
+
119
+ * Fixed parsing source code in JUnit files
120
+
121
+ # 0.7.3
122
+
123
+ * CodeceptJS: Upload all traces and videos from artifacts
124
+ * Fixed reporting skipped test in XML
125
+ * added `--timelimit` option to `report-xml` command line
126
+
127
+ # 0.7.2
128
+
129
+ * Fixed uploading non-existing file
130
+
131
+ # 0.7.1
132
+
133
+ * Support for NUnit XML v3 format
134
+
135
+ # 0.7.0
136
+
137
+ * Support for `@cucumber/cucumber` (>= 7.0) added
138
+ * Initial support for C# and NUnit
139
+
140
+ # 0.6.10
141
+
142
+ * Fixed uploading multilpe artifacts in Playwright
143
+
144
+ # 0.6.9
145
+
146
+ * Fixed pending tests reports for Cypress
147
+
148
+ # 0.6.8
149
+ # 0.6.7
150
+
151
+ * Pytest: fixed creating suites from reports
152
+
153
+ # 0.6.6
154
+
155
+ * JUnit reporter: prefer suite title over testcase classname in a report
156
+
157
+ # 0.6.5
158
+
159
+ * Fixed test statuses for runs in JUnit reporter
160
+
161
+ # 0.6.4
162
+
163
+ * Added `TESTOMATIO_PROCEED=1` param to not close current run
164
+ * Fixed priority of commands from `npx @testomatio/reporter`
165
+
166
+ # 0.6.3
167
+
168
+ * Fixed `npx start-test-run` to launch commands
169
+
170
+ # 0.6.2
171
+
172
+ * Added `--env-file` option to load env variables from env file
173
+
174
+ # 0.6.1
175
+
176
+ * Fixed creating RunGroup with JUnit reporter
177
+
178
+ # 0.6.0
179
+
180
+ * JUnit reporter support
181
+
182
+ # 0.5.10
183
+
184
+ * Fixed reporting Scenario Outline in Cypress-Cucumber
185
+ * Fixed error reports for Cypress when running in Chrome
186
+
187
+ # 0.5.9
188
+
189
+ * Added environment on Cypress report
190
+
191
+ # 0.5.8
192
+
193
+ * Fixed Cypress.io reporting
194
+
195
+ # 0.5.7
196
+
197
+ * Fixed webdriverio artifacts
198
+
199
+ # 0.5.6
200
+
201
+ * Unmark failed CodeceptJS tests as skipped
202
+
203
+ # 0.5.5
204
+
205
+ * Fixed `BeforeSuite` failures in CodeceptJS
206
+
207
+ # 0.5.4
208
+
209
+ Added `TESTOMATIO_CREATE=1` option to create unmatched tests on report
210
+
211
+ ```
212
+ TESTOMATIO_CREATE=1 TESTOMATIO=apiKey npx codeceptjs run
213
+ ```
214
+
215
+ # 0.5.3
216
+
217
+ * Fixed parsing suites
218
+
219
+ # 0.5.2
220
+
221
+ * Fixed multiple upload of artifacts in Cypress.io
222
+
223
+ # 0.5.1
224
+
225
+ * Fixed Cypress.io to report tests inside nested suites
226
+
227
+ # 0.5.0
228
+
229
+ * Added Cypress.io plugin
230
+ * Added artifacts upload to webdriverio
231
+
232
+ # 0.4.6
233
+
234
+ - Fixed CodeceptJS reporter to report tests failed in hooks
235
+
236
+ # 0.4.5
237
+
238
+ - Fixed "Total XX artifacts publicly uploaded to S3 bucket" when no S3 bucket is configured
239
+ - Improved S3 connection error messages
240
+
241
+ # 0.4.4
242
+
243
+ - 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.
244
+
245
+ # 0.4.3
246
+
247
+ - Added `TESTOMATIO_DISABLE_ARTIFACTS` env variable to disable publishing artifacts.
248
+
249
+ # 0.4.2
250
+
251
+ - print version of reporter
252
+ - print number of uploaded artifacts
253
+ - print access mode for uploaded artifacts
254
+
255
+ # 0.4.1
256
+
257
+ Added `global.testomatioArtifacts = []` array which can be used to add arbitrary artifacts to a report.
258
+
259
+ ```js
260
+ // inside a running test:
261
+ global.testomatioArtifacts.push('file/to/upload.png');
262
+ ```
263
+
264
+ # 0.4.0
265
+
266
+ - Playwright: Introduced playwright/test support with screenshots and video artifacts
267
+
268
+ > Known issues: reporting using projects configured in Playwright does not work yet
269
+
270
+ - CodeceptJS: added video uploads
271
+
272
+ # 0.3.16
273
+
274
+ - CodeceptJS: fixed reporting tests with empty steps (on retry)
275
+
276
+ # 0.3.15
277
+
278
+ - Finish Run via API:
279
+
280
+ ```
281
+ TESTOMATIO={apiKey} TESTOMATIO_RUN={runId} npx @testomatio/reporter@latest --finish
282
+ ```
283
+
284
+ # 0.3.14
285
+
286
+ - Create an empty Run via API:
287
+
288
+ ```
289
+ TESTOMATIO={apiKey} npx @testomatio/reporter@latest --launch
290
+ ```
291
+
292
+ # 0.3.13
293
+
294
+ - Checking for a valid report URL
295
+ - Sending unlimited data on test report
296
+
297
+ # 0.3.12
298
+
299
+ - Fixed submitting arbitrary data on a test run
300
+ - Jest: fixed sending errors with stack traces
301
+ - Cypress: fixed sending reports
302
+
303
+ # 0.3.11
304
+
305
+ - Fixed circular JSON reference when submitting data to Testomatio
306
+
307
+ # 0.3.10
308
+
309
+ - Minor fixes
310
+
311
+ # 0.3.9
312
+
313
+ - Making all reporters to run without API key
314
+
315
+ # 0.3.8
316
+
317
+ - Fixed `npx start-test-run` to work with empty API keys
318
+
319
+ # 0.3.7
320
+
321
+ - Fixed release
322
+
323
+ # 0.3.6
324
+
325
+ - Update title and rungroup on start for scheduled runs.
326
+
327
+ # 0.3.5
328
+
329
+ - Added `TESTOMATIO_RUN` environment variable to pass id of a specific run to report
330
+
331
+ # 0.3.4
332
+
333
+ - Minor fixes
334
+
335
+ # 0.3.3
336
+
337
+ - [CodeceptJS] Fixed stack trace reporting
338
+ - [CodeceptJS] Fixed displaying of nested steps
339
+ - [CodeceptJS][mocha] Added assertion diff to report
340
+
341
+ # 0.3.2
342
+
343
+ - Fixed error message for S3 uploading
344
+
345
+ # 0.3.1
346
+
347
+ - [CodeceptJS] Better formatter for nested structures and BDD tests
348
+
349
+ # 0.3.0
350
+
351
+ - Added `TESTOMATIO_TITLE` env variable to set a name for Run
352
+ - Added `TESTOMATIO_RUNGROUP_TITLE` env variable to attach Run to RunGroup
353
+ - Added `TESTOMATIO_ENV` env variable to attach additional env values to report
354
+ - [CodeceptJS] **CodeceptJS v3 support**
355
+ - [CodeceptJS] Dropped support for CodeceptJS 2
356
+ - [CodeceptJS] Added support for before hooks
357
+ - [CodeceptJS] Log of steps
358
+ - [CodeceptJS] Upload screenshots of failed tests to S3
359
+ - [CodeceptJS] Updated to use with parallel execution
@@ -78,8 +78,35 @@ function CodeceptReporter(config) {
78
78
  global.testomatioDataStore.steps = [];
79
79
  });
80
80
 
81
+ let hookSteps = [];
82
+ let suiteHookRunning = false;
83
+
84
+ event.dispatcher.on(event.suite.before, (suite) => {
85
+ suiteHookRunning = true;
86
+ hookSteps = [];
87
+ global.testomatioDataStore.steps = [];
88
+ });
89
+
90
+ event.dispatcher.on(event.test.before, () => {
91
+ suiteHookRunning = false;
92
+ global.testomatioDataStore.steps = []
93
+ });
94
+
95
+ event.dispatcher.on(event.hook.started, (suite) => {
96
+ // global.testomatioDataStore.steps = [];
97
+ });
98
+
99
+ event.dispatcher.on(event.hook.passed, (suite) => {
100
+ if (suiteHookRunning) hookSteps.push(...global.testomatioDataStore.steps);
101
+ });
102
+
103
+ event.dispatcher.on(event.hook.failed, (suite) => {
104
+ if (suiteHookRunning) hookSteps.push(...global.testomatioDataStore.steps);
105
+ });
106
+
81
107
  event.dispatcher.on(event.test.started, test => {
82
108
  testTimeMap[test.id] = Date.now();
109
+
83
110
  if (global.testomatioDataStore) global.testomatioDataStore.currentlyRunningTestId = getIdFromTestTitle(test.title);
84
111
  });
85
112
 
@@ -89,7 +116,7 @@ function CodeceptReporter(config) {
89
116
  await Promise.all(reportTestPromises);
90
117
 
91
118
  if (upload.isArtifactsEnabled()) {
92
- uploadAttachments(client, videos, '🎞️ Uploading', 'video');
119
+ uploadAttachments(client, videos, '🎞️ Uploading', 'video');
93
120
  uploadAttachments(client, traces, '📁 Uploading', 'trace');
94
121
  }
95
122
 
@@ -109,7 +136,7 @@ function CodeceptReporter(config) {
109
136
  suite_title: test.parent && test.parent.title,
110
137
  message: testObj.message,
111
138
  time: getDuration(test),
112
- steps: global.testomatioDataStore.steps.join('\n') || null,
139
+ steps: [...hookSteps, ...global.testomatioDataStore.steps].join('\n') || null,
113
140
  test_id: testId,
114
141
  });
115
142
  // output.stop();
@@ -133,6 +160,7 @@ function CodeceptReporter(config) {
133
160
  ...stripExampleFromTitle(title),
134
161
  suite_title: suite.title,
135
162
  test_id: testId,
163
+ steps: hookSteps.join('\n') || null,
136
164
  error,
137
165
  time: 0,
138
166
  });
@@ -147,9 +175,6 @@ function CodeceptReporter(config) {
147
175
  failedTests.push(id || title);
148
176
  let testId = parseTest(tags);
149
177
  const testObj = getTestAndMessage(title);
150
- if (error && error.stack && test.steps && test.steps.length) {
151
- error.stack = test.steps[test.steps.length - 1].line();
152
- }
153
178
 
154
179
  const files = [];
155
180
  if (artifacts.screenshot) files.push({ path: artifacts.screenshot, type: 'image/png' });
@@ -164,7 +189,7 @@ function CodeceptReporter(config) {
164
189
  message: testObj.message,
165
190
  time: getDuration(test),
166
191
  files,
167
- steps: global.testomatioDataStore?.steps?.join('\n') || null,
192
+ steps: [...hookSteps, ...global.testomatioDataStore.steps].join('\n') || null,
168
193
  })
169
194
  .then(pipes => {
170
195
  testId = pipes.filter(p => p.pipe.includes('Testomatio'))[0]?.result?.data?.test_id;
@@ -10,6 +10,7 @@ const testomatioReporter = on => {
10
10
  const client = new TestomatClient({ apiKey: process.env.TESTOMATIO });
11
11
 
12
12
  on('before:run', async (run) => {
13
+ // TODO: looks like client.env does not exist
13
14
  if (!client.env) {
14
15
  client.env = `${run.browser.displayName},${run.system.osName}`
15
16
  }
@@ -48,10 +49,16 @@ const testomatioReporter = on => {
48
49
  }
49
50
  }
50
51
 
51
- const screenshots = results.screenshots
52
- .filter(screenshot => screenshot.path.includes(title))
53
- .filter(screenshot => screenshot.testAttemptIndex === lastAttemptIndex)
54
- .map(screenshot => screenshot.path);
52
+ const screenshots = Array.isArray(results.screenshots)
53
+ ? results.screenshots
54
+ .filter(
55
+ screenshot =>
56
+ screenshot?.path &&
57
+ screenshot?.path.includes(title) &&
58
+ screenshot?.takenAt
59
+ )
60
+ .map(screenshot => screenshot.path)
61
+ : [];
55
62
 
56
63
  const files = [...videos, ...screenshots];
57
64
 
@@ -53,6 +53,12 @@ program
53
53
 
54
54
  let exitCode = 0;
55
55
 
56
+ if (!command.split) {
57
+ process.exitCode = 255;
58
+ console.log(APP_PREFIX, `No command provided. Use -c option to launch a test runner.`);
59
+ return;
60
+ }
61
+
56
62
  const client = new TestomatClient({ apiKey, title, parallel: true });
57
63
 
58
64
  if(filter) {
@@ -74,12 +80,6 @@ program
74
80
  }
75
81
  }
76
82
 
77
- if (!command.split) {
78
- process.exitCode = 255;
79
- console.log(APP_PREFIX, `No command provided. Use -c option to launch a test runner.`);
80
- return;
81
- }
82
-
83
83
  const testCmds = command.split(' ');
84
84
  console.log(APP_PREFIX, `🚀 Running`, chalk.green(command));
85
85
 
package/lib/config.js ADDED
@@ -0,0 +1,24 @@
1
+ // This file is used to read environment variables from .env file and process.env
2
+
3
+ // ! uncommenting next line leads ro reading vars from .env file
4
+ // require('dotenv').config();
5
+ const debug = require('debug')('@testomatio/reporter:config');
6
+
7
+ /* for possibility to use multiple env files (reading different paths)
8
+ const dotenv = require('dotenv');
9
+ const envFileVars = dotenv.config({ path: '.env' }).parsed; */
10
+
11
+ // select only TESTOMATIO related variables (only to print them in debug)
12
+ const testomatioEnvVars =
13
+ Object.keys(process.env)
14
+ .filter(key => key.startsWith('TESTOMATIO') || key.startsWith('S3_'))
15
+ .reduce((obj, key) => {
16
+ obj[key] = process.env[key];
17
+ return obj;
18
+ }, {}) || {};
19
+ debug('TESTOMATIO variables:', testomatioEnvVars);
20
+
21
+ // includes variables from .env file and process.env
22
+ const config = process.env;
23
+
24
+ module.exports = config;
package/lib/constants.js CHANGED
@@ -20,10 +20,17 @@ const STATUS = {
20
20
  SKIPPED: 'skipped',
21
21
  FINISHED: 'finished',
22
22
  };
23
+ // html pipe var
24
+ const HTML_REPORT = {
25
+ FOLDER: "html-report",
26
+ REPORT_DEFAULT_NAME: "testomatio-report.html",
27
+ TEMPLATE_NAME: 'testomatio.hbs'
28
+ };
23
29
 
24
30
  module.exports = {
25
31
  APP_PREFIX,
26
32
  TESTOMAT_TMP_STORAGE_DIR,
27
33
  CSV_HEADERS,
28
34
  STATUS,
35
+ HTML_REPORT
29
36
  }