@testomatio/reporter 1.0.0-beta.4 → 1.0.0
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 +8 -1
- package/README.md +84 -542
- package/lib/adapter/codecept.js +28 -18
- package/lib/client.js +5 -4
- package/lib/pipe/github.js +2 -2
- package/lib/pipe/testomatio.js +2 -1
- package/lib/reporter.js +2 -1
- package/package.json +1 -1
package/Changelog.md
CHANGED
|
@@ -2,7 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- pending release updates -->
|
|
4
4
|
|
|
5
|
-
* Added `TESTOMATIO_SHARED_RUN` option to use a shared run for parallel executions
|
|
5
|
+
* 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
|
|
6
|
+
* Reworked [documentation](https://github.com/testomatio/reporter/tree/master#readme).
|
|
7
|
+
* Added an option to obtain [S3 configuration](https://github.com/testomatio/reporter/blob/master/docs/artifacts.md#configuration) from Testomat.io
|
|
8
|
+
* Introduced [pipes](https://github.com/testomatio/reporter/blob/master/docs/pipes.md):
|
|
9
|
+
* GitHub
|
|
10
|
+
* GitLab
|
|
11
|
+
* CSV Pipe
|
|
12
|
+
|
|
6
13
|
|
|
7
14
|
# 0.7.6
|
|
8
15
|
|
package/README.md
CHANGED
|
@@ -1,603 +1,145 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Testomatio Reporter
|
|
2
2
|
|
|
3
|
-
Library for sending test run reports to your [testomat.io](https://testomat.io) project.
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Get the `{API_KEY}` from testomat.
|
|
8
|
-
|
|
9
|
-
You can refer sample tests from example folder of this repo. This is a basic example. If you need something full fledged you can refer this [example repo](https://github.com/testomatio/examples).
|
|
10
|
-
|
|
11
|
-
Add `@testomatio/reporter` package to your project:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm i @testomatio/reporter --save
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
For testcafe use testcafe reporter:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm i testcafe-reporter-testomatio
|
|
21
|
-
```
|
|
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
|
-
|
|
36
|
-
## Usage
|
|
37
|
-
|
|
38
|
-
### CodeceptJS
|
|
39
|
-
|
|
40
|
-
Make sure you load all your tests using [check-tests](https://github.com/testomatio/check-tests#cli).
|
|
41
|
-
|
|
42
|
-
Add plugin to [codecept conf](https://github.com/testomatio/reporter/blob/master/example/codecept/codecept.conf.js#L23):
|
|
43
|
-
|
|
44
|
-
```javascript
|
|
45
|
-
plugins: {
|
|
46
|
-
testomatio: {
|
|
47
|
-
enabled: true,
|
|
48
|
-
require: '@testomatio/reporter/lib/adapter/codecept',
|
|
49
|
-
apiKey: process.env.TESTOMATIO || 'API_KEY', // pass in api key via config or env variable
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Run the following command from you project folder:
|
|
55
|
-
|
|
56
|
-
```bash
|
|
57
|
-
TESTOMATIO={API_KEY} npx codeceptjs run
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
#### CodeceptJS Parallel Run
|
|
61
|
-
|
|
62
|
-
If tests run parallel, like workers in CodeceptJS use `start-test-run` command to get proper reports:
|
|
63
|
-
|
|
64
|
-
```bash
|
|
65
|
-
TESTOMATIO={API_KEY} npx start-test-run -c 'npx codeceptjs run-workers 2'
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
> Specify a command to run with `-c` option in `start-test-run`
|
|
69
|
-
|
|
70
|
-
Use `--env-file <envfile>` option to load environment variables from .env file. Inside env file TESTOMATIO credentials like `TESTOMATIO` api key or [S3 config](#attaching-test-artifacts) can be stored.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
### Playwright
|
|
74
|
-
|
|
75
|
-
Add a reporter to Playwright config:
|
|
76
|
-
|
|
77
|
-
```javascript
|
|
78
|
-
reporter: [
|
|
79
|
-
['list'],
|
|
80
|
-
[
|
|
81
|
-
'@testomatio/reporter/lib/adapter/playwright.js',
|
|
82
|
-
{
|
|
83
|
-
apiKey: process.env.TESTOMATIO,
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
];
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Run the following command from you project folder:
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
TESTOMATIO={API_KEY} npx playwright test
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Mocha
|
|
96
|
-
|
|
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).
|
|
98
|
-
|
|
99
|
-
Run the following command from you project folder:
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
mocha --reporter ./node_modules/testomat-reporter/lib/adapter/mocha.js --reporter-options apiKey={API_KEY}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Jest
|
|
106
|
-
|
|
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).
|
|
108
|
-
|
|
109
|
-
Add the following line to [jest.config.js](https://github.com/testomatio/reporter/blob/master/example/jest/jest.config.js#L100):
|
|
110
|
-
|
|
111
|
-
```javascript
|
|
112
|
-
reporters: ['default', ['@testomatio/reporter/lib/adapter/jest.js', { apiKey: process.env.TESTOMATIO }]],
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Run your tests.
|
|
116
|
-
|
|
117
|
-
### Cucumber
|
|
118
|
-
|
|
119
|
-
Load you test using [`check-cucumber`](https://github.com/testomatio/check-cucumber).
|
|
120
|
-
|
|
121
|
-
Run the following command from you project folder:
|
|
122
|
-
|
|
123
|
-
```bash
|
|
124
|
-
TESTOMATIO={API_KEY} ./node_modules/.bin/cucumber-js --format ./node_modules/@testomatio/reporter/lib/adapter/cucumber.js
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### TestCafe
|
|
128
|
-
|
|
129
|
-
Load the test using using `check-tests`.
|
|
130
|
-
|
|
131
|
-
Run the following command from you project folder:
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
TESTOMATIO={API_KEY} npx testcafe chrome -r testomatio
|
|
135
|
-
```
|
|
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
|
-
|
|
148
|
-
### Cypress
|
|
149
|
-
|
|
150
|
-
Load the test using using `check-tests`.
|
|
151
|
-
|
|
152
|
-
Register our `cypress-plugin` in `cypress/plugins/index.js`:
|
|
153
|
-
|
|
154
|
-
```javascript
|
|
155
|
-
const testomatioReporter = require('@testomatio/reporter/lib/adapter/cypress-plugin');
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* @type {Cypress.PluginConfig}
|
|
159
|
-
*/
|
|
160
|
-
module.exports = (on, config) => {
|
|
161
|
-
// `on` is used to hook into various events Cypress emits
|
|
162
|
-
// `config` is the resolved Cypress config
|
|
163
|
-
|
|
164
|
-
testomatioReporter(on, config);
|
|
165
|
-
|
|
166
|
-
return config;
|
|
167
|
-
};
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
Run the following command from you project folder:
|
|
171
|
-
|
|
172
|
-
```bash
|
|
173
|
-
TESTOMATIO={API_KEY} npx cypress run
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
### Protractor
|
|
177
|
-
|
|
178
|
-
Load the test using using `check-tests`.
|
|
179
|
-
|
|
180
|
-
Add the following lines to [conf.js](https://github.com/angular/protractor/blob/5.4.1/example/conf.js):
|
|
181
|
-
|
|
182
|
-
```javascript
|
|
183
|
-
const JasmineReporter = require('@testomatio/reporter/lib/adapter/jasmine');
|
|
184
|
-
|
|
185
|
-
exports.config = {
|
|
186
|
-
onPrepare: () => {
|
|
187
|
-
jasmine.getEnv().addReporter(new JasmineReporter({ apiKey: process.env.TESTOMATIO }));
|
|
188
|
-
},
|
|
189
|
-
};
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
Run the following command from you project folder:
|
|
193
|
-
|
|
194
|
-
```bash
|
|
195
|
-
TESTOMATIO={API_KEY} npx start-test-run -c 'npx protractor conf.js'
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### WebdriverIO
|
|
199
|
-
|
|
200
|
-
Load the test using using `check-tests`.
|
|
201
|
-
|
|
202
|
-
Add the following lines to [wdio.conf.js](https://webdriver.io/docs/configurationfile/):
|
|
203
|
-
|
|
204
|
-
```javascript
|
|
205
|
-
const testomatio = require('@testomatio/reporter/lib/adapter/webdriver');
|
|
206
|
-
|
|
207
|
-
exports.config = {
|
|
208
|
-
// ...
|
|
209
|
-
reporters: [
|
|
210
|
-
[testomatio, {
|
|
211
|
-
apiKey: $ {
|
|
212
|
-
process.env.TESTOMATIO
|
|
213
|
-
}
|
|
214
|
-
}]
|
|
215
|
-
]
|
|
216
|
-
}
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
For making screenshots on failed tests add the following hook to `wdio.conf.js`:
|
|
220
|
-
|
|
221
|
-
```js
|
|
222
|
-
afterTest: function (test, context, { error, result, duration, passed, retries }) {
|
|
223
|
-
if (error) {
|
|
224
|
-
browser.takeScreenshot()
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
Run the following command from you project folder:
|
|
230
|
-
|
|
231
|
-
```bash
|
|
232
|
-
TESTOMATIO={API_KEY} npx start-test-run -c 'npx wdio wdio.conf.js'
|
|
233
|
-
```
|
|
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.
|
|
4
|
+
👋 Hey, do you need some test reporting?
|
|
258
5
|
|
|
259
|
-
|
|
6
|
+
Testomat.io Reporter is a library that integrates with popular **JavaScript and TypeScript** test frameworks to provide a common interface for test reporting. By default, Testomat.io Reporter works with our reporting cloud service [Testomat.io App](https://testomat.io), however it is not locked to it. Reporter can be used as a standalone tool.
|
|
260
7
|
|
|
261
|
-
|
|
8
|
+
## Features
|
|
262
9
|
|
|
263
|
-
|
|
10
|
+
Testomat.io Reporter (this npm package) supports:
|
|
264
11
|
|
|
265
|
-
|
|
12
|
+
* 🏄 Integarion with all popular [JavaScript/TypeScript frameworks](./docs/frameworks.md)
|
|
13
|
+
* 🗄️ Screenshots, videos, traces [uploaded into S3 bucket](./docs/artifacts.md)
|
|
14
|
+
* 🔎 Stack traces and error messages
|
|
15
|
+
* 🐙 [GitHub](./docs/pipes.md#github-pipe) & [GitLab](./docs/pipes.md#gitlab-pipe) integration
|
|
16
|
+
* 🚅 Realtime reports
|
|
17
|
+
* 🗃️ Other test frameworks supported via [JUNit XML](./docs/junit.md)
|
|
18
|
+
* 🚶♀️ Steps *(work in progress)*
|
|
19
|
+
* ☁️ Custom properties and metadata *(work in progress)*
|
|
20
|
+
* 💯 Free & open-source.
|
|
21
|
+
* 📊 Public and private Run reports on cloud via [Testomat.io App](https://testomat.io) 👇
|
|
266
22
|
|
|
267
|
-
Testomat.io will not only create a run report but also collect all information about tests, including source code, and create tests in a system as regular importer do. The only difference that normal process of Testomat.io import does not require executing tests on import, while importing via repoter requires to have tests executed and XML report provided.
|
|
268
23
|
|
|
269
|
-
|
|
24
|
+

|
|
270
25
|
|
|
271
|
-
|
|
272
|
-
* Python (Pytest)
|
|
273
|
-
* Minitest (Ruby)
|
|
274
|
-
* PHPUnit (PHP)
|
|
275
|
-
* NUnit (C#)
|
|
26
|
+
## How It Works
|
|
276
27
|
|
|
28
|
+
Testomat.io Reporter provides common API to store and organize test reports.
|
|
29
|
+
It can receive test result data from any [test framework](./docs/frameworks.md) and send it to different services via [pipes](./docs/pipes.md).
|
|
277
30
|
|
|
278
|
-
|
|
31
|
+
| 🌊 Input | 📊 Output |
|
|
32
|
+
|---------------|----------------------------------------|
|
|
33
|
+
| Playwright | Report to GitHub |
|
|
34
|
+
| Cypress | Report to GitLab |
|
|
35
|
+
| Jest | Report to [Testomat.io](https://testomat.io) |
|
|
36
|
+
| ... | ... your custom report |
|
|
279
37
|
|
|
280
|
-
|
|
38
|
+
If you use multiple test frameworks and you need to use one customizable reporter, check Testomat.io Reporter, as you can adjust it once and attach it to all your projects.
|
|
281
39
|
|
|
282
|
-
|
|
283
|
-
npm i @testomatio/reporter@latest --save-dev
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
Run your test framework and generate a JUnit report.
|
|
288
|
-
|
|
289
|
-
Then import XML report into Testomat.io
|
|
290
|
-
|
|
291
|
-
```
|
|
292
|
-
TESTOMATIO={API_KEY} npx report-xml "{pattern}" --lang={lang}
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
* `pattern` - is a glob pattern to match all XML files from report. For instance, `"test/report/**.xml"` or just `report.xml`
|
|
296
|
-
* `--lang` option can be specified to identify source code of the project. Example: `--lang=Ruby` or `--lang=Java` or `--lang=Python`. Possible values:
|
|
297
|
-
* `c#`
|
|
298
|
-
* `java`
|
|
299
|
-
* `ruby`
|
|
300
|
-
* `python`
|
|
301
|
-
* `php`
|
|
302
|
-
* `--java-tests` option is avaiable for Java projects, and can be set if path to tests is different then `src/test/java`. When this option is enable, `lang` option is automatically set to `java`
|
|
303
|
-
* `--env-file <envfile>` option to load environment variables from .env file. Inside env file TESTOMATIO credentials like `TESTOMATIO` api key or [S3 config](#attaching-test-artifacts) can be stored.
|
|
304
|
-
* `--timelimit <time>` set a timer to silently kill a long-running reporter process due to network or other issues. For instance, use `--set-timeout=3` to stop process after 3 secs.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
> *Notice:* All options from [Advanced Usage](#advanced-usage) are also available for JUnit reporter
|
|
308
|
-
|
|
309
|
-
Check the list of examples:
|
|
310
|
-
|
|
311
|
-
#### Example: Pytest
|
|
312
|
-
|
|
313
|
-
Run pytest tests and generate a report to `report.xml`:
|
|
314
|
-
|
|
315
|
-
```
|
|
316
|
-
pytest --junit-xml report.xml
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
Import report with this command
|
|
320
|
-
|
|
321
|
-
```
|
|
322
|
-
TESTOMATIO={API_KEY} npx report-xml report.xml --lang=python
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
#### Example: JUnit with Maven
|
|
326
|
-
|
|
327
|
-
Run tests via Maven, make sure JUnit report was configured in `pom.xml`.
|
|
328
|
-
|
|
329
|
-
```
|
|
330
|
-
mvn clean test
|
|
331
|
-
```
|
|
332
|
-
|
|
333
|
-
Import report with this command:
|
|
334
|
-
|
|
335
|
-
```
|
|
336
|
-
TESTOMATIO={API_KEY} npx report-xml "target/surefire-reports/*.xml" --java-tests
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
> You can specify `--java-test` option to set a path to tests if they are located in path other than `src/test/java`
|
|
340
|
-
|
|
341
|
-
#### Example: NUnit
|
|
342
|
-
|
|
343
|
-
Generate NUnit XML report and run the following code:
|
|
344
|
-
|
|
345
|
-
```
|
|
346
|
-
TESTOMATIO={API_KEY} npx report-xml "report.xml" --lang="c#"
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
#### Example: Ruby on Rails with Minitest
|
|
350
|
-
|
|
351
|
-
```ruby
|
|
352
|
-
# test_helper.rb:
|
|
353
|
-
|
|
354
|
-
reporters = [Minitest::Reporters::DefaultReporter.new(color: true)]
|
|
355
|
-
# enable JUnit reporter
|
|
356
|
-
reporters << Minitest::Reporters::JUnitReporter.new
|
|
357
|
-
|
|
358
|
-
Minitest::Reporters.use! reporters
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
Launch tests:
|
|
362
|
-
|
|
363
|
-
```
|
|
364
|
-
rails test
|
|
365
|
-
```
|
|
366
|
-
|
|
367
|
-
Import reports from `test/reports` directory:
|
|
368
|
-
|
|
369
|
-
```
|
|
370
|
-
TESTOMATIO={API_KEY} npx report-xml "test/reports/*.xml" --lang ruby
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
### Artifacts
|
|
374
|
-
|
|
375
|
-
Screenshots or videos from tests are uploaded if a test contains output with a path to file of following format:
|
|
40
|
+

|
|
376
41
|
|
|
377
|
-
|
|
378
|
-
file://path/to/screenshot.png
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
For instance, inside Java test you can use `System.out.println` to print a path to file that should be uploaded as a screenshot.
|
|
382
|
-
|
|
383
|
-
```java
|
|
384
|
-
System.out.println("file://" + pathToScreenshot);
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
This will produce XML report which contains path to a file:
|
|
388
|
-
|
|
389
|
-
```xml
|
|
390
|
-
<testcase>
|
|
391
|
-
<system-out><![CDATA[
|
|
392
|
-
file://path/to/scrrenshot.png
|
|
393
|
-
]]></system-out>
|
|
394
|
-
</testcase>
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
When uploaded XML report, all files from `file://` will be uploaded to corresponding tests.
|
|
42
|
+
Artifacts like screenshots, videos, traces, are **uploaded to your own cloud storage** via S3 protocol. Artifacts can be uplaoded privately or publicly, and used in reports.
|
|
398
43
|
|
|
44
|
+
## Installation
|
|
399
45
|
|
|
400
|
-
|
|
46
|
+
To enable Testomat.io Reporter install `@testomatio/reporter` package
|
|
401
47
|
|
|
402
|
-
### Create Unmatched Tests
|
|
403
48
|
|
|
404
|
-
|
|
49
|
+
Use one of your favorite package managers:
|
|
405
50
|
|
|
406
|
-
```bash
|
|
407
|
-
TESTOMATIO={API_KEY} TESTOMATIO_CREATE=1 <actual run command>
|
|
408
51
|
```
|
|
409
|
-
|
|
410
|
-
### Add Report to Run by ID
|
|
411
|
-
|
|
412
|
-
This feature is widely used when a run is executed on CI.
|
|
413
|
-
A run is created before the test is started and it is marked as `scheduled`. Then
|
|
414
|
-
a report is assigned to that run using `TESTOMATIO_RUN` environment variable and `{RUN_ID}` of a run:
|
|
415
|
-
|
|
416
|
-
```bash
|
|
417
|
-
TESTOMATIO={API_KEY} TESTOMATIO_RUN={RUN_ID} <actual run command>
|
|
52
|
+
npm install @testomatio/reporter --save-dev
|
|
418
53
|
```
|
|
419
54
|
|
|
420
|
-
### Do Not Finalize Run
|
|
421
|
-
|
|
422
|
-
If multiple reports are added to the same run, each of them should not finalize the run.
|
|
423
|
-
In this case use `TESTOMATIO_PROCEED=1` environment variable, so the Run will be shown as `Running`
|
|
424
|
-
|
|
425
55
|
```
|
|
426
|
-
|
|
56
|
+
pnpm install @testomatio/reporter --save-dev
|
|
427
57
|
```
|
|
428
58
|
|
|
429
|
-
After all reports were attached and run can be execute the following command:
|
|
430
|
-
|
|
431
59
|
```
|
|
432
|
-
|
|
60
|
+
yarn add @testomatio/reporter --dev
|
|
433
61
|
```
|
|
434
62
|
|
|
435
|
-
|
|
63
|
+
## Getting Started
|
|
436
64
|
|
|
437
|
-
|
|
65
|
+
### 1️⃣ Attach Reporter to the Test Runner
|
|
438
66
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
67
|
+
* #### [Playwright](./docs/frameworks.md#playwright)
|
|
68
|
+
* #### [CodeceptJS](./docs/frameworks.md#CodeceptJS)
|
|
69
|
+
* #### [Cypress](./docs/frameworks.md#Cypress)
|
|
70
|
+
* #### [Jest](./docs/frameworks.md#Jest)
|
|
71
|
+
* #### [Mocha](./docs/frameworks.md#Mocha)
|
|
72
|
+
* #### [WebDriverIO](./docs/frameworks.md#WebDriverIO)
|
|
73
|
+
* #### [TestCafe](./docs/frameworks.md#TestCafe)
|
|
74
|
+
* #### [Detox](./docs/frameworks.md#Detox)
|
|
75
|
+
* #### [Codeception](https://github.com/testomatio/php-reporter)
|
|
76
|
+
* #### [Newman (Postman)](./docs/frameworks.md#Newman)
|
|
77
|
+
* #### [JUnit](./docs/junit.md#junit)
|
|
78
|
+
* #### [NUnit](./docs/junit.md#nunit)
|
|
79
|
+
* #### [PyTest](./docs/junit.md#pytest)
|
|
80
|
+
* #### [PHPUnit](./docs/junit.md#phpunit)
|
|
81
|
+
* #### [Protractor](./docs/frameworks.md#protractor)
|
|
442
82
|
|
|
443
|
-
|
|
83
|
+
or any [other via JUnit](./docs/junit.md) report....
|
|
444
84
|
|
|
445
|
-
|
|
85
|
+
### 2️⃣ Configure Reports
|
|
446
86
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
87
|
+
* [Create report on Testomat.io](./docs/pipes.md#testomatio-pipe).
|
|
88
|
+
* [Create brief summary report for GitHub Pull Request](./docs/pipes.md#github-pipe) 👇
|
|
89
|
+
* [Create brief summary report for GitLab Merge Request](./docs/pipes.md#gitlab-pipe).
|
|
90
|
+
* [Configure other pipes](./docs/pipes.md) for other ways to process test results output.
|
|
450
91
|
|
|
451
|
-
We recommend using a commit hash as a title to create a new Run. In this case we ensure that run title is unique and will be the same for all parallel jobs running exactly for this commit.
|
|
452
92
|
|
|
93
|
+

|
|
453
94
|
|
|
454
|
-
|
|
95
|
+
GitHub report published as a comment to Pull Request:
|
|
455
96
|
|
|
456
|
-
|
|
97
|
+
### 3️⃣ Enable Artifacts Storage
|
|
457
98
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
```
|
|
99
|
+
1. Create bucket on AWS, Google Cloud, or any other cloud storage provider supporting S3 protocol.
|
|
100
|
+
2. [Pass S3 credentials](./docs/artifacts.md) to reporter to enable artifacts uploading.
|
|
461
101
|
|
|
462
|
-
###
|
|
102
|
+
### 4️⃣ Add to CI Pipeline
|
|
463
103
|
|
|
464
|
-
|
|
104
|
+
After you tested reporter locally add it to your CI pipeline.
|
|
465
105
|
|
|
466
|
-
|
|
467
|
-
TESTOMATIO={API_KEY} TESTOMATIO_ENV="Windows, Chrome" <actual run command>
|
|
468
|
-
```
|
|
106
|
+
> We prepared some [example workflows](./docs/workflows.md) that might help you to get it running.
|
|
469
107
|
|
|
470
|
-
|
|
471
|
-
Add an env to run by specifying the `TESTOMATIO_CSV_FILENAME` variable.
|
|
108
|
+
---
|
|
472
109
|
|
|
473
|
-
|
|
110
|
+
🎉 **You are all set!**
|
|
474
111
|
|
|
475
|
-
|
|
476
|
-
TESTOMATIO={API_KEY} TESTOMATIO_CSV_FILENAME="report.csv" <actual run command>
|
|
477
|
-
```
|
|
112
|
+
Bring this reporter on CI and never lose test results again!
|
|
478
113
|
|
|
479
|
-
2) using unique report name:
|
|
480
114
|
|
|
481
|
-
|
|
482
|
-
TESTOMATIO={API_KEY} TESTOMATIO_CSV_FILENAME="test.csv" <actual run command>
|
|
483
|
-
```
|
|
484
|
-
_It's create a new /export folder with csv files_
|
|
115
|
+
## Documentation
|
|
485
116
|
|
|
117
|
+
* 🛠️ [Frameworks](./docs/frameworks.md)
|
|
118
|
+
* ⛲ [Pipes](./docs/pipes.md)
|
|
119
|
+
* 📓 [JUnit](./docs/junit.md)
|
|
120
|
+
* 🗄️ [Artifacts](./docs/artifacts.md)
|
|
121
|
+
* 🔂 [Workflows](./docs/workflows.md)
|
|
486
122
|
|
|
487
|
-
|
|
123
|
+
## Development
|
|
488
124
|
|
|
489
|
-
To save a test artifacts (screenshots and videos) of a failed test use S3 storage.
|
|
490
|
-
Please note, that the **storage is not connected to Testomatio**.
|
|
491
|
-
This allows you to store your artifacts on your own account and not expose S3 credentials.
|
|
492
125
|
|
|
493
|
-
|
|
126
|
+
### REST API
|
|
494
127
|
|
|
495
|
-
|
|
496
|
-
- **S3_BUCKET** - Bucket name.
|
|
497
|
-
- **S3_ACCESS_KEY_ID** - Access key.
|
|
498
|
-
- **S3_SECRET_ACCESS_KEY** - Secret.
|
|
499
|
-
- **S3_ENDPOINT** - for providers other than AWS
|
|
128
|
+
Testomat.io App uses REST API to collect data from the reporter.
|
|
500
129
|
|
|
501
|
-
|
|
502
|
-
In this case uploaded files will be publicly accessible in Internet.
|
|
503
|
-
These public links will be used by [testomat.io](https://testomat.io) to display images and videos.
|
|
130
|
+
[👉 API Reference](https://testomatio.github.io/reporter/)
|
|
504
131
|
|
|
505
|
-
|
|
506
|
-
Then update provide the same S3 credentials in "Settings > Artifacts" section of a [testomat.io](https://testomat.io) project,
|
|
507
|
-
so [testomat.io](https://testomat.io) could connect to the same bucket and fetch uploaded artifacts.
|
|
508
|
-
Links to files will be pre-signed and expires automatically in 10 minutes.
|
|
132
|
+
### Debug Logs
|
|
509
133
|
|
|
510
|
-
|
|
134
|
+
To enable verbose logging run tests with `DEBUG` environment variable:
|
|
511
135
|
|
|
512
|
-
|
|
136
|
+
To print all reporter logs:
|
|
513
137
|
|
|
514
|
-
```bash
|
|
515
|
-
TESTOMATIO_PRIVATE_ARTIFACTS=1
|
|
516
|
-
S3_ACCESS_KEY_ID=11111111111111111111
|
|
517
|
-
S3_SECRET_ACCESS_KEY=2222222222222222222222222222222222222222222
|
|
518
|
-
S3_BUCKET=artifacts
|
|
519
|
-
S3_REGION=us-west-1
|
|
520
138
|
```
|
|
521
|
-
|
|
522
|
-
##### DigitalOcean
|
|
523
|
-
|
|
524
|
-
```bash
|
|
525
|
-
TESTOMATIO_PRIVATE_ARTIFACTS=1
|
|
526
|
-
S3_ENDPOINT=https://ams3.digitaloceanspaces.com
|
|
527
|
-
S3_ACCESS_KEY_ID=11111111111111111111
|
|
528
|
-
S3_SECRET_ACCESS_KEY=2222222222222222222222222222222222222222222
|
|
529
|
-
S3_BUCKET=artifacts
|
|
530
|
-
S3_REGION=ams3
|
|
139
|
+
DEBUG=@testomatio/reporter:*
|
|
531
140
|
```
|
|
141
|
+
To print all reporter logs of a specific pipe:
|
|
532
142
|
|
|
533
|
-
##### Minio
|
|
534
|
-
|
|
535
|
-
```bash
|
|
536
|
-
S3_ENDPOINT=http://company.storage.com
|
|
537
|
-
S3_ACCESS_KEY_ID=minio
|
|
538
|
-
S3_SECRET_ACCESS_KEY=minio123
|
|
539
|
-
S3_BUCKET=testomatio
|
|
540
|
-
S3_FORCE_PATH_STYLE=true
|
|
541
143
|
```
|
|
542
|
-
|
|
543
|
-
> It is important to add S3_FORCE_PATH_STYLE var for minio setup
|
|
544
|
-
|
|
545
|
-
For local testing, it is recommended to store configuration in `.env` file. If you load configuration from a test runner, use [dotenv](https://www.npmjs.com/package/dotenv) library to load it.
|
|
546
|
-
|
|
547
|
-
If you run a reporter via `start-test-run` or `report-xml` command use `--env-file` option to load variables from .env file:
|
|
548
|
-
|
|
549
|
-
```
|
|
550
|
-
npx start-test-run --env-file .env
|
|
551
|
-
npx report-xml --env-file .env
|
|
144
|
+
DEBUG=@testomatio/reporter:pipe:github
|
|
552
145
|
```
|
|
553
|
-
|
|
554
|
-
On CI set environment variables in CI config.
|
|
555
|
-
|
|
556
|
-
Test artifacts are automatically uploaded for these test runners:
|
|
557
|
-
|
|
558
|
-
- CodeceptJS
|
|
559
|
-
- Playwright
|
|
560
|
-
- Cypress
|
|
561
|
-
- WebdriverIO
|
|
562
|
-
|
|
563
|
-
To manually attach an artifact and upload it for a test use `global.testomatioArtifacts` array:
|
|
564
|
-
|
|
565
|
-
```javascript
|
|
566
|
-
// attach a picture inside a test
|
|
567
|
-
global.testomatioArtifacts.push('img/file.png');
|
|
568
|
-
// attach a picture and add a name to it
|
|
569
|
-
global.testomatioArtifacts.push({ name: 'Screenshot', path: 'img/file.png' });
|
|
570
|
-
```
|
|
571
|
-
|
|
572
|
-
Artifacts will be uploaded for the current test when it is finished.
|
|
573
|
-
|
|
574
|
-
To disable uploading artifacts add `TESTOMATIO_DISABLE_ARTIFACTS` environment variable:
|
|
575
|
-
|
|
576
|
-
```bash
|
|
577
|
-
TESTOMATIO_DISABLE_ARTIFACTS=1
|
|
578
|
-
```
|
|
579
|
-
|
|
580
|
-
### Starting an Empty Run
|
|
581
|
-
|
|
582
|
-
If you want to create a run and obtain its `{RUN_ID}` from [testomat.io](https://testomat.io) you can use `--launch` option:
|
|
583
|
-
|
|
584
|
-
```bash
|
|
585
|
-
TESTOMATIO={API_KEY} npx start-test-run --launch
|
|
586
|
-
```
|
|
587
|
-
|
|
588
|
-
This command will return `{RUN_ID}` which you can pass to other testrunner processes.
|
|
589
|
-
|
|
590
|
-
> When executed with `--launch` a command provided by `-c` flag is ignored
|
|
591
|
-
|
|
592
|
-
### Manually Finishing Run
|
|
593
|
-
|
|
594
|
-
If you want to finish a run started by `--launch` use `--finish` option. `TESTOMATIO_RUN` environment variable is required:
|
|
595
|
-
|
|
596
|
-
```bash
|
|
597
|
-
TESTOMATIO={API_KEY} TESTOMATIO_RUN={RUN_ID} npx start-test-run --finish
|
|
598
|
-
```
|
|
599
|
-
|
|
600
|
-
### Debug logs
|
|
601
|
-
Pass `DEBUG` variable with module name e.g. `DEBUG=@testomatio/reporter:pipe:github`.
|
|
602
|
-
(Module name could be taken directly from the required module code).
|
|
603
|
-
To log all debug info pass `DEBUG=*`.
|
package/lib/adapter/codecept.js
CHANGED
|
@@ -33,6 +33,7 @@ if (MAJOR_VERSION < 3) {
|
|
|
33
33
|
function CodeceptReporter(config) {
|
|
34
34
|
let failedTests = [];
|
|
35
35
|
let videos = [];
|
|
36
|
+
let traces = [];
|
|
36
37
|
const reportTestPromises = [];
|
|
37
38
|
|
|
38
39
|
const testTimeMap = {};
|
|
@@ -54,6 +55,7 @@ function CodeceptReporter(config) {
|
|
|
54
55
|
event.dispatcher.on(event.all.before, () => {
|
|
55
56
|
recorder.add('Creating new run', () => client.createRun());
|
|
56
57
|
videos = [];
|
|
58
|
+
traces = [];
|
|
57
59
|
});
|
|
58
60
|
|
|
59
61
|
event.dispatcher.on(event.test.before, () => {
|
|
@@ -70,25 +72,13 @@ function CodeceptReporter(config) {
|
|
|
70
72
|
});
|
|
71
73
|
|
|
72
74
|
event.dispatcher.on(event.all.result, async () => {
|
|
75
|
+
debug('waiting for all tests to be reported');
|
|
73
76
|
// all tests were reported and we can upload videos
|
|
74
77
|
await Promise.all(reportTestPromises);
|
|
75
78
|
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const promises = [];
|
|
80
|
-
for (const video of videos) {
|
|
81
|
-
const { testId, title, path, type } = video;
|
|
82
|
-
const file = { path, type, title };
|
|
83
|
-
promises.push(
|
|
84
|
-
client.addTestRun(undefined, {
|
|
85
|
-
...stripExampleFromTitle(title),
|
|
86
|
-
test_id: testId,
|
|
87
|
-
files: [file],
|
|
88
|
-
}),
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
await Promise.all(promises);
|
|
79
|
+
if (upload.isArtifactsEnabled()) {
|
|
80
|
+
uploadAttachments(client, videos, '🎞️ Uploading', 'video');
|
|
81
|
+
uploadAttachments(client, traces, '📁 Uploading', 'trace');
|
|
92
82
|
}
|
|
93
83
|
|
|
94
84
|
const status = failedTests.length === 0 ? STATUS.PASSED : STATUS.FAILED;
|
|
@@ -166,9 +156,11 @@ function CodeceptReporter(config) {
|
|
|
166
156
|
}).then(pipes => {
|
|
167
157
|
testId = pipes.filter(p => p.pipe.includes('Testomatio'))[0]?.result?.data?.test_id;
|
|
168
158
|
|
|
159
|
+
debug("artifacts", artifacts);
|
|
160
|
+
|
|
169
161
|
for (const aid in artifacts) {
|
|
170
|
-
if (aid.startsWith('video')) videos.push({ testId, title, path: artifacts[aid], type: 'video/webm' });
|
|
171
|
-
if (aid.startsWith('trace'))
|
|
162
|
+
if (aid.startsWith('video')) videos.push({ testId, title, path: artifacts[aid], type: 'video/webm' });
|
|
163
|
+
if (aid.startsWith('trace')) traces.push({ testId, title, path: artifacts[aid], type: 'application/zip' });
|
|
172
164
|
}
|
|
173
165
|
});
|
|
174
166
|
|
|
@@ -242,6 +234,24 @@ function CodeceptReporter(config) {
|
|
|
242
234
|
});
|
|
243
235
|
}
|
|
244
236
|
|
|
237
|
+
async function uploadAttachments(client, attachments, messagePrefix, attachmentType) {
|
|
238
|
+
if (attachments.length > 0) {
|
|
239
|
+
console.log(APP_PREFIX, `Attachments: ${messagePrefix} ${attachments.length} ${attachmentType}/-s ...`);
|
|
240
|
+
|
|
241
|
+
const promises = attachments.map(async (attachment) => {
|
|
242
|
+
const { testId, title, path, type } = attachment;
|
|
243
|
+
const file = { path, type, title };
|
|
244
|
+
return client.addTestRun(undefined, {
|
|
245
|
+
...stripExampleFromTitle(title),
|
|
246
|
+
test_id: testId,
|
|
247
|
+
files: [file],
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
await Promise.all(promises);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
245
255
|
function parseTest(tags) {
|
|
246
256
|
if (tags) {
|
|
247
257
|
for (const tag of tags) {
|
package/lib/client.js
CHANGED
|
@@ -11,6 +11,7 @@ const pipesFactory = require('./pipe');
|
|
|
11
11
|
/**
|
|
12
12
|
* @typedef {import('../types').TestData} TestData
|
|
13
13
|
* @typedef {import('../types').RunStatus} RunStatus
|
|
14
|
+
* @typedef {import('../types').PipeResult} PipeResult
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
class Client {
|
|
@@ -33,7 +34,7 @@ class Client {
|
|
|
33
34
|
/**
|
|
34
35
|
* Used to create a new Test run
|
|
35
36
|
*
|
|
36
|
-
* @returns {Promise<
|
|
37
|
+
* @returns {Promise<any>} - resolves to Run id which should be used to update / add test
|
|
37
38
|
*/
|
|
38
39
|
createRun() {
|
|
39
40
|
// all pipes disabled, skipping
|
|
@@ -61,7 +62,7 @@ class Client {
|
|
|
61
62
|
* @param {string|undefined} status
|
|
62
63
|
* @param {TestData} [testData]
|
|
63
64
|
* @param {string[]} [storeArtifacts]
|
|
64
|
-
* @returns {Promise<
|
|
65
|
+
* @returns {Promise<PipeResult[]>}
|
|
65
66
|
*/
|
|
66
67
|
async addTestRun(status, testData, storeArtifacts = []) {
|
|
67
68
|
// all pipes disabled, skipping
|
|
@@ -147,7 +148,7 @@ class Client {
|
|
|
147
148
|
const result = await p.addTest(data);
|
|
148
149
|
return { pipe: p.toString(), result };
|
|
149
150
|
} catch (err) {
|
|
150
|
-
console.log(APP_PREFIX,
|
|
151
|
+
console.log(APP_PREFIX, p.toString(), err);
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
)));
|
|
@@ -160,7 +161,7 @@ class Client {
|
|
|
160
161
|
* Updates the status of the current test run and finishes the run.
|
|
161
162
|
* @param {RunStatus} status - The status of the current test run. Must be one of "passed", "failed", or "finished"
|
|
162
163
|
* @param {boolean} [isParallel] - Whether the current test run was executed in parallel with other tests.
|
|
163
|
-
* @returns {Promise<
|
|
164
|
+
* @returns {Promise<any>} - A Promise that resolves when finishes the run.
|
|
164
165
|
*/
|
|
165
166
|
updateRunStatus(status, isParallel = false) {
|
|
166
167
|
// all pipes disabled, skipping
|
package/lib/pipe/github.js
CHANGED
|
@@ -39,8 +39,8 @@ class GitHubPipe {
|
|
|
39
39
|
async createRun() {}
|
|
40
40
|
|
|
41
41
|
addTest(test) {
|
|
42
|
-
debug('Adding test:', test);
|
|
43
42
|
if (!this.isEnabled) return;
|
|
43
|
+
debug('Adding test:', test);
|
|
44
44
|
|
|
45
45
|
const index = this.tests.findIndex(t => isSameTest(t, test));
|
|
46
46
|
// update if they were already added
|
|
@@ -200,7 +200,7 @@ function fullName(t) {
|
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
async function deletePreviousReport(octokit, owner, repo, issue, hiddenCommentData) {
|
|
203
|
-
if (process.env.
|
|
203
|
+
if (process.env.GH_KEEP_OUTDATED_REPORTS) return;
|
|
204
204
|
|
|
205
205
|
// get comments
|
|
206
206
|
let comments = [];
|
package/lib/pipe/testomatio.js
CHANGED
|
@@ -169,6 +169,7 @@ class TestomatioPipe {
|
|
|
169
169
|
|
|
170
170
|
module.exports = TestomatioPipe;
|
|
171
171
|
|
|
172
|
+
|
|
172
173
|
function setS3Credentials(artifacts) {
|
|
173
174
|
if (!Object.keys(artifacts).length) return;
|
|
174
175
|
|
|
@@ -181,4 +182,4 @@ function setS3Credentials(artifacts) {
|
|
|
181
182
|
if (artifacts.ENDPOINT) process.env.S3_ENDPOINT = artifacts.ENDPOINT;
|
|
182
183
|
if (artifacts.presign) process.env.TESTOMATIO_PRIVATE_ARTIFACTS = '1';
|
|
183
184
|
resetConfig();
|
|
184
|
-
}
|
|
185
|
+
}
|
package/lib/reporter.js
CHANGED