From 4cb7560dbfa995be663e7ccce8775c4467c535d5 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 24 Sep 2025 09:03:26 +0200 Subject: [PATCH 1/3] Update reports.md: use "reporter" option instead of CLI --- docs/reports.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/reports.md b/docs/reports.md index 07bf89bad..a3c0c73be 100644 --- a/docs/reports.md +++ b/docs/reports.md @@ -212,16 +212,17 @@ Additional configuration should be added to `codecept.conf.js` to print xml repo ```json "mocha": { + "repporter": "mocha-junit-reporter", "reporterOptions": { "mochaFile": "output/result.xml" } }, ``` -Execute CodeceptJS with JUnit reporter: +Execute CodeceptJS: ```sh -codeceptjs run --reporter mocha-junit-reporter +codeceptjs run ``` Result will be located at `output/result.xml` file. @@ -315,16 +316,17 @@ Configure it to use `output` directory to print HTML reports: ```json "mocha": { + "reporter": "mochawesome", "reporterOptions": { "reportDir": "output" } }, ``` -Execute CodeceptJS with HTML reporter: +Execute CodeceptJS: ```sh -codeceptjs run --reporter mochawesome +codeceptjs run ``` Result will be located at `output/index.html` file. @@ -388,6 +390,7 @@ Configure mocha-multi with reports that you want: ```json "mocha": { + "reporter": "mocha-multi", "reporterOptions": { "codeceptjs-cli-reporter": { "stdout": "-", @@ -414,10 +417,10 @@ Configure mocha-multi with reports that you want: } ``` -Execute CodeceptJS with mocha-multi reporter: +Execute CodeceptJS: ```sh -npx codeceptjs run --reporter mocha-multi +npx codeceptjs run ``` This will give you cli with steps in console and HTML report in `output` directory. From 387d1f5dba2713e0e675552f9da186c9705c647d Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 24 Sep 2025 09:14:43 +0200 Subject: [PATCH 2/3] typo --- docs/reports.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reports.md b/docs/reports.md index a3c0c73be..b5c03947b 100644 --- a/docs/reports.md +++ b/docs/reports.md @@ -212,7 +212,7 @@ Additional configuration should be added to `codecept.conf.js` to print xml repo ```json "mocha": { - "repporter": "mocha-junit-reporter", + "reporter": "mocha-junit-reporter", "reporterOptions": { "mochaFile": "output/result.xml" } From f323fe970fdc5bc7b19be75d430f9cb5b4575c3f Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Mon, 6 Oct 2025 10:09:12 +0200 Subject: [PATCH 3/3] add config-only variant as an alternative --- docs/reports.md | 129 ++++++++++++++++++++++++++++++------------------ 1 file changed, 82 insertions(+), 47 deletions(-) diff --git a/docs/reports.md b/docs/reports.md index b5c03947b..0f138fc89 100644 --- a/docs/reports.md +++ b/docs/reports.md @@ -35,6 +35,7 @@ GitHub -- ``` output steps use `--steps` option: + ``` npx codeceptjs run --steps ``` @@ -73,12 +74,10 @@ GitHub -- To get additional information about test execution use `--debug` option. - ``` npx codeceptjs run --debug ``` - This will show execution steps as well as notices from test runner. To get even more information with more technical details like error stack traces, and global promises, or events use `--verbose` mode. @@ -141,7 +140,6 @@ npx codecepjs dry-run --debug > ℹ If you use custom JavaScript code inside tests, or rely on values from `grab*` commands, dry-run may produce error output. - ## Testomat.io [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 To receive run reports you should: -* [Sign up](https://app.testomat.io/users/sign_up) at Testomat.io -* Create a new "Classical" project (select "BDD" project if you use CodeceptJS in BDD mode) -* Select "Import from Source Code" -* Select "CodeceptJS" as testing framework and JavaScript or TypeScript as a language. If you use BDD select "Gherkin" as language. -* 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. -* After tests are imported, go to Runs tab and select "Setup automated tests". -* Follow the instructions: - +- [Sign up](https://app.testomat.io/users/sign_up) at Testomat.io +- Create a new "Classical" project (select "BDD" project if you use CodeceptJS in BDD mode) +- Select "Import from Source Code" +- Select "CodeceptJS" as testing framework and JavaScript or TypeScript as a language. If you use BDD select "Gherkin" as language. +- 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. +- After tests are imported, go to Runs tab and select "Setup automated tests". +- Follow the instructions: ![image](https://user-images.githubusercontent.com/77803888/151834217-5da44d92-a59a-458d-8856-64ce61bf3a38.png) -* You will need to install `@testomatio/reporter` package and enable it as a plugin in codeceptjs config: +- You will need to install `@testomatio/reporter` package and enable it as a plugin in codeceptjs config: ```js plugins: { @@ -176,14 +173,11 @@ plugins: { } ``` -* Run tests with `TESTOMATIO=` env variable and API key provided by Testomat.io -* See the run report is created and updated in realtime. - +- Run tests with `TESTOMATIO=` env variable and API key provided by Testomat.io +- See the run report is created and updated in realtime. [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. - - ## ReportPortal 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. Use official [CodeceptJS Agent for ReportPortal](https://github.com/reportportal/agent-js-codecept/) to start publishing your test results. - ## XML Use default xunit reporter of Mocha to print xml reports. Provide `--reporter xunit` to get the report to screen. @@ -212,21 +205,35 @@ Additional configuration should be added to `codecept.conf.js` to print xml repo ```json "mocha": { - "reporter": "mocha-junit-reporter", "reporterOptions": { "mochaFile": "output/result.xml" } }, ``` -Execute CodeceptJS: +Execute CodeceptJS with JUnit reporter: ```sh -codeceptjs run +codeceptjs run --reporter mocha-junit-reporter ``` Result will be located at `output/result.xml` file. +Alternatively, the reporter name can be added to the configuration file as well. In this case, CodeceptJS can be executed without additional CLI options. + +```json + "mocha": { + "reporter": "mocha-junit-reporter", + "reporterOptions": { + "mochaFile": "output/result.xml" + } + }, +``` + +```sh +codeceptjs run +``` + ## Html ### Built-in HTML Reporter @@ -253,13 +260,13 @@ exports.config = { plugins: { htmlReporter: { enabled: true, - output: './output', // Directory for the report - reportFileName: 'report.html', // Name of the HTML file - includeArtifacts: true, // Include screenshots/artifacts - showSteps: true, // Show individual test steps - showSkipped: true // Show skipped tests - } - } + output: './output', // Directory for the report + reportFileName: 'report.html', // Name of the HTML file + includeArtifacts: true, // Include screenshots/artifacts + showSteps: true, // Show individual test steps + showSkipped: true, // Show skipped tests + }, + }, } ``` @@ -300,6 +307,7 @@ npm i mochawesome ``` If you get an error like this + ```sh "mochawesome" reporter not found @@ -316,21 +324,35 @@ Configure it to use `output` directory to print HTML reports: ```json "mocha": { - "reporter": "mochawesome", "reporterOptions": { "reportDir": "output" } }, ``` -Execute CodeceptJS: +Execute CodeceptJS with mochawesome reporter: ```sh -codeceptjs run +codeceptjs run --reporter mochawesome ``` Result will be located at `output/index.html` file. +Alternatively, the reporter name can be added to the configuration file as well. In this case, CodeceptJS can be executed without additional CLI options. + +```json + "mocha": { + "reporter": "mochawesome", + "reporterOptions": { + "reportDir": "output" + } + }, +``` + +```sh +codeceptjs run +``` + ### Advanced usage Want to have screenshots for failed tests? @@ -351,7 +373,7 @@ Then tests with failure will have screenshots. This helper should be configured in codecept.conf.ts - `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. -- `disableScreenshots` (optional, default: false) - don't save screenshot on failure. This option should be the same as in common helper. +- `disableScreenshots` (optional, default: false) - don't save screenshot on failure. This option should be the same as in common helper. Also if you will add Mochawesome helper, then you will able to add custom context in report: @@ -360,21 +382,22 @@ Also if you will add Mochawesome helper, then you will able to add custom contex Adds context to executed test in HTML report: ```js -I.addMochawesomeContext('simple string'); -I.addMochawesomeContext('http://www.url.com/pathname'); -I.addMochawesomeContext('http://www.url.com/screenshot-maybe.jpg'); -I.addMochawesomeContext({title: 'expected output', - value: { - a: 1, - b: '2', - c: 'd' - } -}); +I.addMochawesomeContext('simple string') +I.addMochawesomeContext('http://www.url.com/pathname') +I.addMochawesomeContext('http://www.url.com/screenshot-maybe.jpg') +I.addMochawesomeContext({ + title: 'expected output', + value: { + a: 1, + b: '2', + c: 'd', + }, +}) ``` ##### Parameters -- `context` string, url, path to screenshot, object. See [this](https://www.npmjs.com/package/mochawesome#adding-test-context) +- `context` string, url, path to screenshot, object. See [this](https://www.npmjs.com/package/mochawesome#adding-test-context) ## Multi Reports @@ -390,7 +413,6 @@ Configure mocha-multi with reports that you want: ```json "mocha": { - "reporter": "mocha-multi", "reporterOptions": { "codeceptjs-cli-reporter": { "stdout": "-", @@ -417,14 +439,28 @@ Configure mocha-multi with reports that you want: } ``` -Execute CodeceptJS: +Execute CodeceptJS with mocha-multi reporter: ```sh -npx codeceptjs run +npx codeceptjs run --reporter mocha-multi ``` This will give you cli with steps in console and HTML report in `output` directory. +Alternatively, the reporter name can be added to the configuration file as well. In this case, CodeceptJS can be executed without additional CLI options. + +```json + "mocha": { + "reporter": "mocha-multi", + "reporterOptions": { + ... + } + } +``` + +```sh +codeceptjs run +``` ## Testrail @@ -443,7 +479,6 @@ npm i codeceptjs-testrail --save Now there is new feature, add the configuration to test run of test plan ![Attachemnt for failed case](http://g.recordit.co/uQLvQUq7cT.gif) - ## Tesults 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.