@testomatio/reporter 1.0.0-beta.4 → 1.1.0-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/README.md +88 -540
- package/lib/{ArtifactStorage.js → _ArtifactStorageOld.js} +10 -0
- package/lib/adapter/codecept.js +28 -18
- package/lib/adapter/jest.js +15 -2
- package/lib/adapter/mocha.js +1 -1
- package/lib/artifactStorage.js +25 -0
- package/lib/client.js +21 -13
- package/lib/constants.js +5 -0
- package/lib/dataStorage.js +172 -0
- package/lib/logger.js +221 -0
- package/lib/pipe/github.js +2 -2
- package/lib/pipe/testomatio.js +2 -1
- package/lib/reporter.js +8 -2
- package/lib/util.js +53 -33
- package/package.json +1 -1
- package/Changelog.md +0 -257
package/README.md
CHANGED
|
@@ -1,603 +1,151 @@
|
|
|
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.
|
|
4
|
+
👋 Hey, do you need some test reporting?
|
|
255
5
|
|
|
256
|
-
|
|
257
|
-
To leave previous report pass `GITLAB_KEEP_OUTDATED_REPORTS=1` env variable.
|
|
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.
|
|
258
7
|
|
|
259
|
-
##
|
|
8
|
+
## Features
|
|
260
9
|
|
|
261
|
-
|
|
10
|
+
Testomat.io Reporter (this npm package) supports:
|
|
262
11
|
|
|
263
|
-
|
|
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
|
+
* 📄 Logger *(work in progress, supports Jest for now)*
|
|
20
|
+
* ☁️ Custom properties and metadata *(work in progress)*
|
|
21
|
+
* 💯 Free & open-source.
|
|
22
|
+
* 📊 Public and private Run reports on cloud via [Testomat.io App](https://testomat.io) 👇
|
|
264
23
|
|
|
265
|
-
JUnit XML format is standard among test runners on various platforms. Testomat.io can load XML reports from test runners and create tests in a project from it. If your framework is not supported yet, generate JUnit report and upload it into Testomat.io
|
|
266
24
|
|
|
267
|
-
|
|
25
|
+

|
|
268
26
|
|
|
269
|
-
|
|
27
|
+
## How It Works
|
|
270
28
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
* Minitest (Ruby)
|
|
274
|
-
* PHPUnit (PHP)
|
|
275
|
-
* NUnit (C#)
|
|
29
|
+
Testomat.io Reporter provides common API to store and organize test reports.
|
|
30
|
+
It can receive test result data from any [test framework](./docs/frameworks.md) and send it to different services via [pipes](./docs/pipes.md).
|
|
276
31
|
|
|
32
|
+
| 🌊 Input | 📊 Output |
|
|
33
|
+
|---------------|----------------------------------------|
|
|
34
|
+
| Playwright | Report to GitHub |
|
|
35
|
+
| Cypress | Report to GitLab |
|
|
36
|
+
| Jest | Report to [Testomat.io](https://testomat.io) |
|
|
37
|
+
| ... | ... your custom report |
|
|
277
38
|
|
|
278
|
-
|
|
39
|
+
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.
|
|
279
40
|
|
|
280
|
-
|
|
41
|
+

|
|
281
42
|
|
|
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:
|
|
43
|
+
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.
|
|
376
44
|
|
|
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.
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
## Advanced Usage
|
|
401
|
-
|
|
402
|
-
### Create Unmatched Tests
|
|
403
|
-
|
|
404
|
-
Testomat.io will not create tests from the report if they have not been previously imported. To create tests during the report `TESTOMATIO_CREATE` option can be used:
|
|
405
|
-
|
|
406
|
-
```bash
|
|
407
|
-
TESTOMATIO={API_KEY} TESTOMATIO_CREATE=1 <actual run command>
|
|
408
|
-
```
|
|
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:
|
|
45
|
+
## Installation
|
|
415
46
|
|
|
416
|
-
|
|
417
|
-
TESTOMATIO={API_KEY} TESTOMATIO_RUN={RUN_ID} <actual run command>
|
|
418
|
-
```
|
|
47
|
+
To enable Testomat.io Reporter install `@testomatio/reporter` package
|
|
419
48
|
|
|
420
|
-
### Do Not Finalize Run
|
|
421
49
|
|
|
422
|
-
|
|
423
|
-
In this case use `TESTOMATIO_PROCEED=1` environment variable, so the Run will be shown as `Running`
|
|
50
|
+
Use one of your favorite package managers:
|
|
424
51
|
|
|
425
52
|
```
|
|
426
|
-
|
|
53
|
+
npm install @testomatio/reporter --save-dev
|
|
427
54
|
```
|
|
428
55
|
|
|
429
|
-
After all reports were attached and run can be execute the following command:
|
|
430
|
-
|
|
431
|
-
```
|
|
432
|
-
TESTOMATIO={API_KEY} TESTOMATIO_RUN={RUN_ID} npx start-test-run --finish
|
|
433
56
|
```
|
|
434
|
-
|
|
435
|
-
### Setting Report Title
|
|
436
|
-
|
|
437
|
-
Give a title to your reports by passing it as environment variable to `TESTOMATIO_TITLE`.
|
|
438
|
-
|
|
439
|
-
```bash
|
|
440
|
-
TESTOMATIO={API_KEY} TESTOMATIO_TITLE="title for the report" <actual run command>
|
|
57
|
+
pnpm install @testomatio/reporter --save-dev
|
|
441
58
|
```
|
|
442
59
|
|
|
443
|
-
### Reporting Parallel Executionto To Same Run
|
|
444
|
-
|
|
445
|
-
Provide a shared unique title to all runs that will be running in parallel, and add `TESTOMATIO_SHARED_RUN` environment var. So all reports will be sent to this run.
|
|
446
|
-
|
|
447
|
-
```bash
|
|
448
|
-
TESTOMATIO={API_KEY} TESTOMATIO_TITLE="report for commit ${GIT_COMMIT}" TESTOMATIO_SHARED_RUN=1 <actual run command>
|
|
449
60
|
```
|
|
450
|
-
|
|
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
|
-
|
|
453
|
-
|
|
454
|
-
### Adding Report to RunGroup
|
|
455
|
-
|
|
456
|
-
Create/Add run to group by providing `TESTOMATIO_RUNGROUP_TITLE`:
|
|
457
|
-
|
|
458
|
-
```sh
|
|
459
|
-
TESTOMATIO={API_KEY} TESTOMATIO_RUNGROUP_TITLE="Build ${BUILD_ID}" <actual run command>
|
|
61
|
+
yarn add @testomatio/reporter --dev
|
|
460
62
|
```
|
|
461
63
|
|
|
462
|
-
|
|
64
|
+
## Getting Started
|
|
463
65
|
|
|
464
|
-
|
|
66
|
+
### 1️⃣ Attach Reporter to the Test Runner
|
|
465
67
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
68
|
+
* #### [Playwright](./docs/frameworks.md#playwright)
|
|
69
|
+
* #### [CodeceptJS](./docs/frameworks.md#CodeceptJS)
|
|
70
|
+
* #### [Cypress](./docs/frameworks.md#Cypress)
|
|
71
|
+
* #### [Jest](./docs/frameworks.md#Jest)
|
|
72
|
+
* #### [Mocha](./docs/frameworks.md#Mocha)
|
|
73
|
+
* #### [WebDriverIO](./docs/frameworks.md#WebDriverIO)
|
|
74
|
+
* #### [TestCafe](./docs/frameworks.md#TestCafe)
|
|
75
|
+
* #### [Detox](./docs/frameworks.md#Detox)
|
|
76
|
+
* #### [Codeception](https://github.com/testomatio/php-reporter)
|
|
77
|
+
* #### [Newman (Postman)](./docs/frameworks.md#Newman)
|
|
78
|
+
* #### [JUnit](./docs/junit.md#junit)
|
|
79
|
+
* #### [NUnit](./docs/junit.md#nunit)
|
|
80
|
+
* #### [PyTest](./docs/junit.md#pytest)
|
|
81
|
+
* #### [PHPUnit](./docs/junit.md#phpunit)
|
|
82
|
+
* #### [Protractor](./docs/frameworks.md#protractor)
|
|
469
83
|
|
|
470
|
-
|
|
471
|
-
Add an env to run by specifying the `TESTOMATIO_CSV_FILENAME` variable.
|
|
84
|
+
or any [other via JUnit](./docs/junit.md) report....
|
|
472
85
|
|
|
473
|
-
|
|
86
|
+
### 2️⃣ Configure Reports
|
|
474
87
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
88
|
+
* [Create report on Testomat.io](./docs/pipes.md#testomatio-pipe).
|
|
89
|
+
* [Create brief summary report for GitHub Pull Request](./docs/pipes.md#github-pipe) 👇
|
|
90
|
+
* [Create brief summary report for GitLab Merge Request](./docs/pipes.md#gitlab-pipe).
|
|
91
|
+
* [Configure other pipes](./docs/pipes.md) for other ways to process test results output.
|
|
478
92
|
|
|
479
|
-
2) using unique report name:
|
|
480
93
|
|
|
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_
|
|
94
|
+

|
|
485
95
|
|
|
96
|
+
GitHub report published as a comment to Pull Request:
|
|
486
97
|
|
|
487
|
-
###
|
|
98
|
+
### 3️⃣ Enable Artifacts Storage
|
|
488
99
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
This allows you to store your artifacts on your own account and not expose S3 credentials.
|
|
100
|
+
1. Create bucket on AWS, Google Cloud, or any other cloud storage provider supporting S3 protocol.
|
|
101
|
+
2. [Pass S3 credentials](./docs/artifacts.md) to reporter to enable artifacts uploading.
|
|
492
102
|
|
|
493
|
-
|
|
103
|
+
### 4️⃣ Use Logger
|
|
494
104
|
|
|
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
|
|
105
|
+
Intercept your logger messages or log anything with our [Logger](./docs/logger.md) (_work in progress_).
|
|
500
106
|
|
|
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.
|
|
107
|
+
### 5️⃣ Add to CI Pipeline
|
|
504
108
|
|
|
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.
|
|
109
|
+
After you tested reporter locally add it to your CI pipeline.
|
|
509
110
|
|
|
510
|
-
|
|
111
|
+
> We prepared some [example workflows](./docs/workflows.md) that might help you to get it running.
|
|
511
112
|
|
|
512
|
-
|
|
113
|
+
---
|
|
513
114
|
|
|
514
|
-
|
|
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
|
-
```
|
|
115
|
+
🎉 **You are all set!**
|
|
521
116
|
|
|
522
|
-
|
|
117
|
+
Bring this reporter on CI and never lose test results again!
|
|
523
118
|
|
|
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
|
|
531
|
-
```
|
|
532
119
|
|
|
533
|
-
|
|
120
|
+
## Documentation
|
|
534
121
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
```
|
|
122
|
+
* 🛠️ [Frameworks](./docs/frameworks.md)
|
|
123
|
+
* ⛲ [Pipes](./docs/pipes.md)
|
|
124
|
+
* 📓 [JUnit](./docs/junit.md)
|
|
125
|
+
* 🗄️ [Artifacts](./docs/artifacts.md)
|
|
126
|
+
* 🔂 [Workflows](./docs/workflows.md)
|
|
127
|
+
* 🔂 [Logger](./docs/logger.md)
|
|
542
128
|
|
|
543
|
-
|
|
129
|
+
## Development
|
|
544
130
|
|
|
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
131
|
|
|
547
|
-
|
|
132
|
+
### REST API
|
|
548
133
|
|
|
549
|
-
|
|
550
|
-
npx start-test-run --env-file .env
|
|
551
|
-
npx report-xml --env-file .env
|
|
552
|
-
```
|
|
134
|
+
Testomat.io App uses REST API to collect data from the reporter.
|
|
553
135
|
|
|
554
|
-
|
|
136
|
+
[👉 API Reference](https://testomatio.github.io/reporter/)
|
|
555
137
|
|
|
556
|
-
|
|
138
|
+
### Debug Logs
|
|
557
139
|
|
|
558
|
-
|
|
559
|
-
- Playwright
|
|
560
|
-
- Cypress
|
|
561
|
-
- WebdriverIO
|
|
140
|
+
To enable verbose logging run tests with `DEBUG` environment variable:
|
|
562
141
|
|
|
563
|
-
To
|
|
142
|
+
To print all reporter logs:
|
|
564
143
|
|
|
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
144
|
```
|
|
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
|
|
145
|
+
DEBUG=@testomatio/reporter:*
|
|
578
146
|
```
|
|
147
|
+
To print all reporter logs of a specific pipe:
|
|
579
148
|
|
|
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
149
|
```
|
|
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
|
|
150
|
+
DEBUG=@testomatio/reporter:pipe:github
|
|
598
151
|
```
|
|
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=*`.
|