@testomatio/reporter 0.8.0-beta.9 → 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 +251 -0
- package/README.md +77 -7
- package/lib/ArtifactStorage.js +131 -0
- package/lib/adapter/codecept.js +25 -24
- package/lib/adapter/cucumber/current.js +16 -12
- package/lib/adapter/cucumber/legacy.js +14 -10
- package/lib/adapter/cypress-plugin/index.js +7 -7
- package/lib/adapter/jasmine.js +5 -4
- package/lib/adapter/jest.js +7 -11
- package/lib/adapter/mocha.js +69 -18
- package/lib/adapter/playwright.js +28 -31
- package/lib/adapter/webdriver.js +2 -1
- package/lib/bin/reportXml.js +5 -2
- package/lib/bin/startTest.js +2 -2
- package/lib/client.js +73 -49
- package/lib/constants.js +17 -2
- package/lib/fileUploader.js +103 -64
- package/lib/junit-adapter/csharp.js +0 -1
- package/lib/junit-adapter/index.js +3 -2
- package/lib/pipe/csv.js +133 -0
- package/lib/pipe/github.js +137 -73
- package/lib/pipe/gitlab.js +229 -0
- package/lib/pipe/index.js +27 -12
- package/lib/pipe/testomatio.js +71 -44
- package/lib/reporter.js +2 -0
- package/lib/util.js +46 -13
- package/lib/xmlReader.js +47 -31
- package/package.json +12 -3
- package/testcafe/index.js +0 -61
- package/testcafe/package.json +0 -14
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
|
package/README.md
CHANGED
|
@@ -20,11 +20,24 @@ For testcafe use testcafe reporter:
|
|
|
20
20
|
npm i testcafe-reporter-testomatio
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
For newman use:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm i newman-reporter-testomatio --save-dev
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
>`newman` and `newman-reporter-testomatio` should be installed in the same directory.
|
|
30
|
+
\
|
|
31
|
+
If you run your tests using globally installed newman (`newman run ...`), intall `newman-reporter-testomatio` globally too (`npm i newman-reporter-testomatio -g`).
|
|
32
|
+
\
|
|
33
|
+
If you use locally installed newman (within the project) (`npx newman run ...`), install `newman-reporter-testomatio` locally (`npm i newman-reporter-testomatio`).
|
|
34
|
+
You can verify installed packages via `npm list` or `npm list -g`.
|
|
35
|
+
|
|
23
36
|
## Usage
|
|
24
37
|
|
|
25
38
|
### CodeceptJS
|
|
26
39
|
|
|
27
|
-
Make sure you load all your tests using [check-
|
|
40
|
+
Make sure you load all your tests using [check-tests](https://github.com/testomatio/check-tests#cli).
|
|
28
41
|
|
|
29
42
|
Add plugin to [codecept conf](https://github.com/testomatio/reporter/blob/master/example/codecept/codecept.conf.js#L23):
|
|
30
43
|
|
|
@@ -81,7 +94,7 @@ TESTOMATIO={API_KEY} npx playwright test
|
|
|
81
94
|
|
|
82
95
|
### Mocha
|
|
83
96
|
|
|
84
|
-
Load the test using using `check-
|
|
97
|
+
Load the test using using `check-tests` if not done already. Get the test id from testomat account and add it to your mocha test like in this [example](https://github.com/testomatio/reporter/blob/master/example/mocha/test/index.test.js#L4).
|
|
85
98
|
|
|
86
99
|
Run the following command from you project folder:
|
|
87
100
|
|
|
@@ -91,7 +104,7 @@ mocha --reporter ./node_modules/testomat-reporter/lib/adapter/mocha.js --reporte
|
|
|
91
104
|
|
|
92
105
|
### Jest
|
|
93
106
|
|
|
94
|
-
Load the test using using `check-
|
|
107
|
+
Load the test using using `check-tests`. Add the test id to your tests like in this [example](https://github.com/testomatio/reporter/blob/master/example/jest/index.test.js#L1).
|
|
95
108
|
|
|
96
109
|
Add the following line to [jest.config.js](https://github.com/testomatio/reporter/blob/master/example/jest/jest.config.js#L100):
|
|
97
110
|
|
|
@@ -113,7 +126,7 @@ TESTOMATIO={API_KEY} ./node_modules/.bin/cucumber-js --format ./node_modules/@te
|
|
|
113
126
|
|
|
114
127
|
### TestCafe
|
|
115
128
|
|
|
116
|
-
Load the test using using `check-
|
|
129
|
+
Load the test using using `check-tests`.
|
|
117
130
|
|
|
118
131
|
Run the following command from you project folder:
|
|
119
132
|
|
|
@@ -121,9 +134,20 @@ Run the following command from you project folder:
|
|
|
121
134
|
TESTOMATIO={API_KEY} npx testcafe chrome -r testomatio
|
|
122
135
|
```
|
|
123
136
|
|
|
137
|
+
### Newman (Postman)
|
|
138
|
+
|
|
139
|
+
Run collection and specify `testomatio` as reporter:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
TESTOMATIO={API_KEY} npx newman run {collection_name.json} -r testomatio
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
> _`check-tests` not supported for newman for now, tests will be created on testomatio by default_
|
|
146
|
+
|
|
147
|
+
|
|
124
148
|
### Cypress
|
|
125
149
|
|
|
126
|
-
Load the test using using `check-
|
|
150
|
+
Load the test using using `check-tests`.
|
|
127
151
|
|
|
128
152
|
Register our `cypress-plugin` in `cypress/plugins/index.js`:
|
|
129
153
|
|
|
@@ -151,7 +175,7 @@ TESTOMATIO={API_KEY} npx cypress run
|
|
|
151
175
|
|
|
152
176
|
### Protractor
|
|
153
177
|
|
|
154
|
-
Load the test using using `check-
|
|
178
|
+
Load the test using using `check-tests`.
|
|
155
179
|
|
|
156
180
|
Add the following lines to [conf.js](https://github.com/angular/protractor/blob/5.4.1/example/conf.js):
|
|
157
181
|
|
|
@@ -173,7 +197,7 @@ TESTOMATIO={API_KEY} npx start-test-run -c 'npx protractor conf.js'
|
|
|
173
197
|
|
|
174
198
|
### WebdriverIO
|
|
175
199
|
|
|
176
|
-
Load the test using using `check-
|
|
200
|
+
Load the test using using `check-tests`.
|
|
177
201
|
|
|
178
202
|
Add the following lines to [wdio.conf.js](https://webdriver.io/docs/configurationfile/):
|
|
179
203
|
|
|
@@ -208,6 +232,30 @@ Run the following command from you project folder:
|
|
|
208
232
|
TESTOMATIO={API_KEY} npx start-test-run -c 'npx wdio wdio.conf.js'
|
|
209
233
|
```
|
|
210
234
|
|
|
235
|
+
## Pipes
|
|
236
|
+
Pipes allow you to get report inside different systems (e.g. Pull request comment, database etc)
|
|
237
|
+
For now next pipes available:
|
|
238
|
+
|
|
239
|
+
### GitHub
|
|
240
|
+
This pipe adds comment with run report to GitHub Pull Request.
|
|
241
|
+
|
|
242
|
+
To use it:
|
|
243
|
+
1. run your tests using github actions in Pull Request
|
|
244
|
+
2. pass `GH_PAT` (GitHub Personal Access Token) as environment variable.
|
|
245
|
+
|
|
246
|
+
> Last report (comment) will be replaced with the new one.
|
|
247
|
+
To leave previous report pass `GITHUB_KEEP_OUTDATED_REPORTS=1` env variable.
|
|
248
|
+
|
|
249
|
+
### GitLab
|
|
250
|
+
This pipe adds comment with run report to GitLab Merge Request.
|
|
251
|
+
|
|
252
|
+
To use it:
|
|
253
|
+
1. run your tests in Merge Request (pipeline trigger should be `merge_request`)
|
|
254
|
+
2. pass `GITLAB_PAT` (GitLab Personal Access Token) as environment variable.
|
|
255
|
+
|
|
256
|
+
> Last report (comment) will be replaced with the new one.
|
|
257
|
+
To leave previous report pass `GITLAB_KEEP_OUTDATED_REPORTS=1` env variable.
|
|
258
|
+
|
|
211
259
|
## JUnit Reports
|
|
212
260
|
|
|
213
261
|
> **Notice** JUnit reports are supported since 0.6.0
|
|
@@ -408,6 +456,23 @@ Add environments to run by providing `TESTOMATIO_ENV` as comma seperated values:
|
|
|
408
456
|
TESTOMATIO={API_KEY} TESTOMATIO_ENV="Windows, Chrome" <actual run command>
|
|
409
457
|
```
|
|
410
458
|
|
|
459
|
+
### Save test results to .csv file
|
|
460
|
+
Add an env to run by specifying the `TESTOMATIO_CSV_FILENAME` variable.
|
|
461
|
+
|
|
462
|
+
1) using default report name:
|
|
463
|
+
|
|
464
|
+
```bash
|
|
465
|
+
TESTOMATIO={API_KEY} TESTOMATIO_CSV_FILENAME="report.csv" <actual run command>
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
2) using unique report name:
|
|
469
|
+
|
|
470
|
+
```bash
|
|
471
|
+
TESTOMATIO={API_KEY} TESTOMATIO_CSV_FILENAME="test.csv" <actual run command>
|
|
472
|
+
```
|
|
473
|
+
_It's create a new /export folder with csv files_
|
|
474
|
+
|
|
475
|
+
|
|
411
476
|
### Attaching Test Artifacts
|
|
412
477
|
|
|
413
478
|
To save a test artifacts (screenshots and videos) of a failed test use S3 storage.
|
|
@@ -520,3 +585,8 @@ If you want to finish a run started by `--launch` use `--finish` option. `TESTOM
|
|
|
520
585
|
```bash
|
|
521
586
|
TESTOMATIO={API_KEY} TESTOMATIO_RUN={RUN_ID} npx start-test-run --finish
|
|
522
587
|
```
|
|
588
|
+
|
|
589
|
+
### Debug logs
|
|
590
|
+
Pass `DEBUG` variable with module name e.g. `DEBUG=@testomatio/reporter:pipe:github`.
|
|
591
|
+
(Module name could be taken directly from the required module code).
|
|
592
|
+
To log all debug info pass `DEBUG=*`.
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
const debug = require('debug')('@testomatio/reporter:storage');
|
|
2
|
+
const { join, resolve } = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const uuid = require('uuid');
|
|
6
|
+
const { TESTOMAT_ARTIFACT_SUFFIX } = require('./constants');
|
|
7
|
+
const { specificTestInfo } = require('./util');
|
|
8
|
+
|
|
9
|
+
class ArtifactStorage {
|
|
10
|
+
|
|
11
|
+
constructor(params) {
|
|
12
|
+
this._tmpPrefix = "tsmt_reporter";
|
|
13
|
+
this.isFile = false;
|
|
14
|
+
this.isMemory = true;
|
|
15
|
+
this.storage = params?.toFile;
|
|
16
|
+
|
|
17
|
+
if (this.storage) {
|
|
18
|
+
this.isFile = true;
|
|
19
|
+
this.isMemory = false;
|
|
20
|
+
this.tmpDirFullpath = this.createTestomatTmpDir(this._tmpPrefix);
|
|
21
|
+
debug('SAVE to tmp folder mode enabled!');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static async storeToFile(tmpDirName, artifact, testSuffix = "test") {
|
|
26
|
+
const suffix = TESTOMAT_ARTIFACT_SUFFIX + uuid.v4() + testSuffix;
|
|
27
|
+
const dirpath = join(os.tmpdir(), tmpDirName);
|
|
28
|
+
const filepath = resolve(dirpath, `${suffix}.json`);
|
|
29
|
+
|
|
30
|
+
return fs.promises.appendFile(filepath, JSON.stringify(artifact));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static async artifact(artifact, context) {
|
|
34
|
+
// TODO: mode for different pre-hooks. As variant - "all-tests" || "only_fail"
|
|
35
|
+
// const mode = process.env.TESTOMAT_ARTIFACTS || "only_fail";
|
|
36
|
+
|
|
37
|
+
if (Array.isArray(global.testomatioArtifacts)) {
|
|
38
|
+
debug("Saving artifacts to global storage");
|
|
39
|
+
|
|
40
|
+
global.testomatioArtifacts.push(artifact);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (global?.testomatioArtifacts === undefined) {
|
|
44
|
+
const tmpDirNames = ArtifactStorage.tmpTestomatDirNames();
|
|
45
|
+
|
|
46
|
+
const testSuffix = specificTestInfo(context.test);
|
|
47
|
+
|
|
48
|
+
if (Array.isArray(tmpDirNames) && tmpDirNames.length) {
|
|
49
|
+
debug("Saving artifacts to memory tmp folder");
|
|
50
|
+
|
|
51
|
+
return ArtifactStorage.storeToFile(tmpDirNames[tmpDirNames.length - 1], artifact, testSuffix);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async artifactByTestName(test) {
|
|
57
|
+
const list = [];
|
|
58
|
+
|
|
59
|
+
if (this.isFile && this.tmpDirFullpath) {
|
|
60
|
+
const files = fs.readdirSync(this.tmpDirFullpath);
|
|
61
|
+
|
|
62
|
+
for (const file of files) {
|
|
63
|
+
if (file.includes(test)) {
|
|
64
|
+
const buff = await fs.promises.readFile(`${this.tmpDirFullpath }/${ file}`);
|
|
65
|
+
|
|
66
|
+
list.push(JSON.parse(buff.toString()));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return list;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async tmpContents() {
|
|
75
|
+
const contents = [];
|
|
76
|
+
|
|
77
|
+
if (this.isFile && this.tmpDirFullpath) {
|
|
78
|
+
const files = fs.readdirSync(this.tmpDirFullpath);
|
|
79
|
+
|
|
80
|
+
for (const file of files) {
|
|
81
|
+
const buff = await fs.promises.readFile(`${this.tmpDirFullpath }/${ file}`);
|
|
82
|
+
const content = buff.toString();
|
|
83
|
+
|
|
84
|
+
contents.push(content);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return contents;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
createTestomatTmpDir(clientPrefix) {
|
|
92
|
+
return fs.mkdtempSync(join(os.tmpdir(), clientPrefix));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
clearTmpDirByName(name) {
|
|
96
|
+
const tmpDirPath = join(os.tmpdir(), name);
|
|
97
|
+
|
|
98
|
+
if (fs.existsSync(tmpDirPath)) {
|
|
99
|
+
fs.rmSync(tmpDirPath, { recursive: true });
|
|
100
|
+
debug(` Testomat tmpDir = ${tmpDirPath} was deleted successfully!`);
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static tmpTestomatDirNames() {
|
|
107
|
+
const subname = this._tmpPrefix || "tsmt_reporter";
|
|
108
|
+
|
|
109
|
+
return fs.readdirSync(os.tmpdir(), { withFileTypes: true })
|
|
110
|
+
.filter((item) => item.isDirectory())
|
|
111
|
+
.map((item) => item.name)
|
|
112
|
+
.filter((name) => name.includes(subname));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
cleanup() {
|
|
116
|
+
if (this.isFile && this.tmpDirFullpath) {
|
|
117
|
+
const tmpDirNames = ArtifactStorage.tmpTestomatDirNames();
|
|
118
|
+
|
|
119
|
+
if (Array.isArray(tmpDirNames) && tmpDirNames.length) {
|
|
120
|
+
for (const name of tmpDirNames) {
|
|
121
|
+
this.clearTmpDirByName(name);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
debug("The tmp folder has not been created! Nothing to delete");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
module.exports = ArtifactStorage;
|
package/lib/adapter/codecept.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const TestomatClient = require('../client');
|
|
3
|
+
const { STATUS, APP_PREFIX } = require('../constants');
|
|
4
|
+
const upload = require('../fileUploader');
|
|
5
|
+
const Output = require('../output');
|
|
6
|
+
|
|
1
7
|
if (!global.codeceptjs) {
|
|
2
8
|
// eslint-disable-next-line global-require, import/no-extraneous-dependencies
|
|
3
9
|
global.codeceptjs = require('codeceptjs');
|
|
4
10
|
}
|
|
5
11
|
|
|
6
12
|
const { event, recorder, codecept } = global.codeceptjs;
|
|
7
|
-
const chalk = require('chalk');
|
|
8
|
-
const TestomatClient = require('../client');
|
|
9
|
-
const { FAILED } = require('../constants');
|
|
10
|
-
const TRConstants = require('../constants');
|
|
11
|
-
const upload = require('../fileUploader');
|
|
12
|
-
const Output = require('../output');
|
|
13
13
|
|
|
14
14
|
let currentMetaStep = [];
|
|
15
15
|
let error;
|
|
@@ -35,11 +35,6 @@ function CodeceptReporter(config) {
|
|
|
35
35
|
const testTimeMap = {};
|
|
36
36
|
const { apiKey } = config;
|
|
37
37
|
|
|
38
|
-
if (!apiKey) {
|
|
39
|
-
console.log('TESTOMATIO key is empty, ignoring reports');
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
38
|
const getDuration = test => {
|
|
44
39
|
if (testTimeMap[test.id]) {
|
|
45
40
|
return Date.now() - testTimeMap[test.id];
|
|
@@ -72,16 +67,17 @@ function CodeceptReporter(config) {
|
|
|
72
67
|
});
|
|
73
68
|
|
|
74
69
|
event.dispatcher.on(event.all.result, async () => {
|
|
75
|
-
if (videos.length && upload.isArtifactsEnabled) {
|
|
76
|
-
console.log(
|
|
70
|
+
if (videos.length && upload.isArtifactsEnabled()) {
|
|
71
|
+
console.log(APP_PREFIX, `🎞️ Uploading ${videos.length} videos...`);
|
|
77
72
|
|
|
78
73
|
const promises = [];
|
|
79
74
|
for (const video of videos) {
|
|
80
75
|
const { testId, title, path, type } = video;
|
|
81
76
|
const file = { path, type, title };
|
|
82
77
|
promises.push(
|
|
83
|
-
client.addTestRun(
|
|
78
|
+
client.addTestRun(undefined, {
|
|
84
79
|
...stripExampleFromTitle(title),
|
|
80
|
+
test_id: testId,
|
|
85
81
|
files: [file],
|
|
86
82
|
}),
|
|
87
83
|
);
|
|
@@ -89,7 +85,7 @@ function CodeceptReporter(config) {
|
|
|
89
85
|
await Promise.all(promises);
|
|
90
86
|
}
|
|
91
87
|
|
|
92
|
-
const status = failedTests.length === 0 ?
|
|
88
|
+
const status = failedTests.length === 0 ? STATUS.PASSED : STATUS.FAILED;
|
|
93
89
|
client.updateRunStatus(status);
|
|
94
90
|
});
|
|
95
91
|
|
|
@@ -100,12 +96,13 @@ function CodeceptReporter(config) {
|
|
|
100
96
|
}
|
|
101
97
|
const testId = parseTest(tags);
|
|
102
98
|
const testObj = getTestAndMessage(title);
|
|
103
|
-
client.addTestRun(
|
|
99
|
+
client.addTestRun(STATUS.PASSED, {
|
|
104
100
|
...stripExampleFromTitle(title),
|
|
105
101
|
suite_title: test.parent && test.parent.title,
|
|
106
102
|
message: testObj.message,
|
|
107
103
|
time: getDuration(test),
|
|
108
104
|
steps: output.text(),
|
|
105
|
+
test_id: testId,
|
|
109
106
|
});
|
|
110
107
|
output.stop();
|
|
111
108
|
});
|
|
@@ -124,9 +121,10 @@ function CodeceptReporter(config) {
|
|
|
124
121
|
failedTests.push(id || title);
|
|
125
122
|
const testId = parseTest(tags);
|
|
126
123
|
|
|
127
|
-
client.addTestRun(
|
|
124
|
+
client.addTestRun(STATUS.FAILED, {
|
|
128
125
|
...stripExampleFromTitle(title),
|
|
129
126
|
suite_title: suite.title,
|
|
127
|
+
test_id: testId,
|
|
130
128
|
error,
|
|
131
129
|
time: 0,
|
|
132
130
|
});
|
|
@@ -135,7 +133,7 @@ function CodeceptReporter(config) {
|
|
|
135
133
|
});
|
|
136
134
|
|
|
137
135
|
event.dispatcher.on(event.test.after, test => {
|
|
138
|
-
if (test.state && test.state !== FAILED) return;
|
|
136
|
+
if (test.state && test.state !== STATUS.FAILED) return;
|
|
139
137
|
if (test.err) error = test.err;
|
|
140
138
|
const { id, tags, title, artifacts } = test;
|
|
141
139
|
failedTests.push(id || title);
|
|
@@ -154,8 +152,9 @@ function CodeceptReporter(config) {
|
|
|
154
152
|
if (aid.startsWith('trace')) files.push({ testId: id, title, path: artifacts[aid], type: 'application/zip' });
|
|
155
153
|
}
|
|
156
154
|
|
|
157
|
-
client.addTestRun(
|
|
155
|
+
client.addTestRun(STATUS.FAILED, {
|
|
158
156
|
...stripExampleFromTitle(title),
|
|
157
|
+
test_id: testId,
|
|
159
158
|
suite_title: test.parent && test.parent.title,
|
|
160
159
|
error,
|
|
161
160
|
message: testObj.message,
|
|
@@ -172,8 +171,9 @@ function CodeceptReporter(config) {
|
|
|
172
171
|
|
|
173
172
|
const testId = parseTest(tags);
|
|
174
173
|
const testObj = getTestAndMessage(title);
|
|
175
|
-
client.addTestRun(
|
|
174
|
+
client.addTestRun(STATUS.SKIPPED, {
|
|
176
175
|
...stripExampleFromTitle(title),
|
|
176
|
+
test_id: testId,
|
|
177
177
|
suite_title: test.parent && test.parent.title,
|
|
178
178
|
message: testObj.message,
|
|
179
179
|
time: getDuration(test),
|
|
@@ -212,12 +212,13 @@ function CodeceptReporter(config) {
|
|
|
212
212
|
currentMetaStep = metaSteps;
|
|
213
213
|
stepShift = 2 * shift;
|
|
214
214
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
const durationMs = (+new Date() - (+stepStart));
|
|
216
|
+
let duration = '';
|
|
217
|
+
if (durationMs) {
|
|
218
|
+
duration = repeat(1) + chalk.grey(`(${durationMs}ms)`);
|
|
218
219
|
}
|
|
219
220
|
|
|
220
|
-
if (step.status ===
|
|
221
|
+
if (step.status === STATUS.FAILED) {
|
|
221
222
|
output.push(repeat(stepShift) + chalk.red(step.toString()) + duration);
|
|
222
223
|
} else {
|
|
223
224
|
output.push(repeat(stepShift) + step.toString() + duration);
|