Skip to content

Commit 05c5d06

Browse files
authored
fix(docs): Update reports.md: use "reporter" option instead of CLI (#5211)
* Update reports.md: use "reporter" option instead of CLI * typo * add config-only variant as an alternative
1 parent af28305 commit 05c5d06

File tree

1 file changed

+77
-39
lines changed

1 file changed

+77
-39
lines changed

docs/reports.md

Lines changed: 77 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ GitHub --
3535
```
3636

3737
output steps use `--steps` option:
38+
3839
```
3940
npx codeceptjs run --steps
4041
```
@@ -73,12 +74,10 @@ GitHub --
7374

7475
To get additional information about test execution use `--debug` option.
7576

76-
7777
```
7878
npx codeceptjs run --debug
7979
```
8080

81-
8281
This will show execution steps
8382
as well as notices from test runner. To get even more information with more technical details like error stack traces,
8483
and global promises, or events use `--verbose` mode.
@@ -141,7 +140,6 @@ npx codecepjs dry-run --debug
141140

142141
> ℹ If you use custom JavaScript code inside tests, or rely on values from `grab*` commands, dry-run may produce error output.
143142
144-
145143
## Testomat.io
146144

147145
[Testomat.io](https://testomat.io) is a modern test management tool focused on CodeceptJS and **created by CodeceptJS team**.
@@ -153,18 +151,17 @@ Testomat.io is commercial SaaS service that can receive run reports from local r
153151
154152
To receive run reports you should:
155153

156-
* [Sign up](https://app.testomat.io/users/sign_up) at Testomat.io
157-
* Create a new "Classical" project (select "BDD" project if you use CodeceptJS in BDD mode)
158-
* Select "Import from Source Code"
159-
* Select "CodeceptJS" as testing framework and JavaScript or TypeScript as a language. If you use BDD select "Gherkin" as language.
160-
* Execute provided command in a terminal with your project. This will be "check-tests" or "check-cucmber" command. It scans all your test files and imports them into Testomat.io. This way all your e2e tests will be visible in one UI.
161-
* After tests are imported, go to Runs tab and select "Setup automated tests".
162-
* Follow the instructions:
163-
154+
- [Sign up](https://app.testomat.io/users/sign_up) at Testomat.io
155+
- Create a new "Classical" project (select "BDD" project if you use CodeceptJS in BDD mode)
156+
- Select "Import from Source Code"
157+
- Select "CodeceptJS" as testing framework and JavaScript or TypeScript as a language. If you use BDD select "Gherkin" as language.
158+
- Execute provided command in a terminal with your project. This will be "check-tests" or "check-cucmber" command. It scans all your test files and imports them into Testomat.io. This way all your e2e tests will be visible in one UI.
159+
- After tests are imported, go to Runs tab and select "Setup automated tests".
160+
- Follow the instructions:
164161

165162
![image](https://user-images.githubusercontent.com/77803888/151834217-5da44d92-a59a-458d-8856-64ce61bf3a38.png)
166163

167-
* You will need to install `@testomatio/reporter` package and enable it as a plugin in codeceptjs config:
164+
- You will need to install `@testomatio/reporter` package and enable it as a plugin in codeceptjs config:
168165

169166
```js
170167
plugins: {
@@ -176,14 +173,11 @@ plugins: {
176173
}
177174
```
178175

179-
* Run tests with `TESTOMATIO=` env variable and API key provided by Testomat.io
180-
* See the run report is created and updated in realtime.
181-
176+
- Run tests with `TESTOMATIO=` env variable and API key provided by Testomat.io
177+
- See the run report is created and updated in realtime.
182178

183179
[Testomat.io](https://testomat.io) reporter works in the cloud, so it doesn't require you to install additional software. It can be integrated with your CI service to rerun only failed tests, launch new runs from UI, and send report notifications by email or in Slack, MS Teams, or create issue in Jira.
184180

185-
186-
187181
## ReportPortal
188182

189183
For enterprise grade we reporting we recommend using [ReportPortal](https://reportportal.io).
@@ -195,7 +189,6 @@ Think of it as Kibana but for test reports.
195189

196190
Use official [CodeceptJS Agent for ReportPortal](https://github.com/reportportal/agent-js-codecept/) to start publishing your test results.
197191

198-
199192
## XML
200193

201194
Use default xunit reporter of Mocha to print xml reports. Provide `--reporter xunit` to get the report to screen.
@@ -226,6 +219,21 @@ codeceptjs run --reporter mocha-junit-reporter
226219

227220
Result will be located at `output/result.xml` file.
228221

222+
Alternatively, the reporter name can be added to the configuration file as well. In this case, CodeceptJS can be executed without additional CLI options.
223+
224+
```json
225+
"mocha": {
226+
"reporter": "mocha-junit-reporter",
227+
"reporterOptions": {
228+
"mochaFile": "output/result.xml"
229+
}
230+
},
231+
```
232+
233+
```sh
234+
codeceptjs run
235+
```
236+
229237
## Html
230238

231239
### Built-in HTML Reporter
@@ -252,13 +260,13 @@ exports.config = {
252260
plugins: {
253261
htmlReporter: {
254262
enabled: true,
255-
output: './output', // Directory for the report
256-
reportFileName: 'report.html', // Name of the HTML file
257-
includeArtifacts: true, // Include screenshots/artifacts
258-
showSteps: true, // Show individual test steps
259-
showSkipped: true // Show skipped tests
260-
}
261-
}
263+
output: './output', // Directory for the report
264+
reportFileName: 'report.html', // Name of the HTML file
265+
includeArtifacts: true, // Include screenshots/artifacts
266+
showSteps: true, // Show individual test steps
267+
showSkipped: true, // Show skipped tests
268+
},
269+
},
262270
}
263271
```
264272

@@ -299,6 +307,7 @@ npm i mochawesome
299307
```
300308

301309
If you get an error like this
310+
302311
```sh
303312
"mochawesome" reporter not found
304313

@@ -321,14 +330,29 @@ Configure it to use `output` directory to print HTML reports:
321330
},
322331
```
323332

324-
Execute CodeceptJS with HTML reporter:
333+
Execute CodeceptJS with mochawesome reporter:
325334

326335
```sh
327336
codeceptjs run --reporter mochawesome
328337
```
329338

330339
Result will be located at `output/index.html` file.
331340

341+
Alternatively, the reporter name can be added to the configuration file as well. In this case, CodeceptJS can be executed without additional CLI options.
342+
343+
```json
344+
"mocha": {
345+
"reporter": "mochawesome",
346+
"reporterOptions": {
347+
"reportDir": "output"
348+
}
349+
},
350+
```
351+
352+
```sh
353+
codeceptjs run
354+
```
355+
332356
### Advanced usage
333357

334358
Want to have screenshots for failed tests?
@@ -349,7 +373,7 @@ Then tests with failure will have screenshots.
349373
This helper should be configured in codecept.conf.ts
350374

351375
- `uniqueScreenshotNames` (optional, default: false) - option to prevent screenshot override if you have scenarios with the same name in different suites. This option should be the same as in common helper.
352-
- `disableScreenshots` (optional, default: false) - don't save screenshot on failure. This option should be the same as in common helper.
376+
- `disableScreenshots` (optional, default: false) - don't save screenshot on failure. This option should be the same as in common helper.
353377

354378
Also if you will add Mochawesome helper, then you will able to add custom context in report:
355379

@@ -358,21 +382,22 @@ Also if you will add Mochawesome helper, then you will able to add custom contex
358382
Adds context to executed test in HTML report:
359383

360384
```js
361-
I.addMochawesomeContext('simple string');
362-
I.addMochawesomeContext('http://www.url.com/pathname');
363-
I.addMochawesomeContext('http://www.url.com/screenshot-maybe.jpg');
364-
I.addMochawesomeContext({title: 'expected output',
365-
value: {
366-
a: 1,
367-
b: '2',
368-
c: 'd'
369-
}
370-
});
385+
I.addMochawesomeContext('simple string')
386+
I.addMochawesomeContext('http://www.url.com/pathname')
387+
I.addMochawesomeContext('http://www.url.com/screenshot-maybe.jpg')
388+
I.addMochawesomeContext({
389+
title: 'expected output',
390+
value: {
391+
a: 1,
392+
b: '2',
393+
c: 'd',
394+
},
395+
})
371396
```
372397

373398
##### Parameters
374399

375-
- `context` string, url, path to screenshot, object. See [this](https://www.npmjs.com/package/mochawesome#adding-test-context)
400+
- `context` string, url, path to screenshot, object. See [this](https://www.npmjs.com/package/mochawesome#adding-test-context)
376401

377402
## Multi Reports
378403

@@ -422,6 +447,20 @@ npx codeceptjs run --reporter mocha-multi
422447

423448
This will give you cli with steps in console and HTML report in `output` directory.
424449

450+
Alternatively, the reporter name can be added to the configuration file as well. In this case, CodeceptJS can be executed without additional CLI options.
451+
452+
```json
453+
"mocha": {
454+
"reporter": "mocha-multi",
455+
"reporterOptions": {
456+
...
457+
}
458+
}
459+
```
460+
461+
```sh
462+
codeceptjs run
463+
```
425464

426465
## Testrail
427466

@@ -440,7 +479,6 @@ npm i codeceptjs-testrail --save
440479
Now there is new feature, add the configuration to test run of test plan
441480
![Attachemnt for failed case](http://g.recordit.co/uQLvQUq7cT.gif)
442481

443-
444482
## Tesults
445483

446484
Submit test results data from CodeceptJS to [Tesults](https://www.tesults.com) easily with the [codeceptjs-tesults](https://www.npmjs.com/package/codeceptjs-tesults) plugin. Test results data is submitted automatically after a test run completes.

0 commit comments

Comments
 (0)