|
| 1 | +# Reporters |
| 2 | + |
| 3 | +## Cli (default) |
| 4 | + |
| 5 | +By default CodeceptJS provides cli reporter with console output. |
| 6 | +Test names and failures will be printed to screen. |
| 7 | + |
| 8 | +``` |
| 9 | +GitHub -- |
| 10 | + ✓ search in 2577ms |
| 11 | + ✓ signin in 2170ms |
| 12 | + ✖ register in 1306ms |
| 13 | +
|
| 14 | +-- FAILURES: |
| 15 | +
|
| 16 | + 1) GitHub: register: |
| 17 | + Field q not found by name|text|CSS|XPath |
| 18 | +
|
| 19 | + Scenario Steps: |
| 20 | +
|
| 21 | + - Within .js-signup-form: I.fillField("q", "aaa") at examples/github_test.js:29:7 |
| 22 | + - Within .js-signup-form: I.fillField("user[password]", "user@user.com") at examples/github_test.js:28:7 |
| 23 | + - Within .js-signup-form: I.fillField("user[email]", "user@user.com") at examples/github_test.js:27:7 |
| 24 | + - Within .js-signup-form: I.fillField("user[login]", "User") at examples/github_test.js:26:7 |
| 25 | +
|
| 26 | +
|
| 27 | +
|
| 28 | + Run with --verbose flag to see NodeJS stacktrace |
| 29 | +``` |
| 30 | + |
| 31 | +For dynamic step-by-step output add `--steps` option to `run` command: |
| 32 | + |
| 33 | +``` |
| 34 | +GitHub -- |
| 35 | + search |
| 36 | + • I am on page "https://github.com" |
| 37 | + • I am on page "https://github.com/search" |
| 38 | + • I fill field "Search GitHub", "CodeceptJS" |
| 39 | + • I press key "Enter" |
| 40 | + • I see "Codeception/CodeceptJS", "a" |
| 41 | + ✓ OK in 2681ms |
| 42 | +
|
| 43 | + signin |
| 44 | + • I am on page "https://github.com" |
| 45 | + • I click "Sign in" |
| 46 | + • I see "Sign in to GitHub" |
| 47 | + • I fill field "Username or email address", "something@totest.com" |
| 48 | + • I fill field "Password", "123456" |
| 49 | + • I click "Sign in" |
| 50 | + • I see "Incorrect username or password.", ".flash-error" |
| 51 | + ✓ OK in 2252ms |
| 52 | +
|
| 53 | + register |
| 54 | + • I am on page "https://github.com" |
| 55 | + Within .js-signup-form: |
| 56 | + • I fill field "user[login]", "User" |
| 57 | + • I fill field "user[email]", "user@user.com" |
| 58 | + • I fill field "user[password]", "user@user.com" |
| 59 | + • I fill field "q", "aaa" |
| 60 | + ✖ FAILED in 1260ms |
| 61 | +``` |
| 62 | +To get additional information about test execution use `--debug` option. This will show execution steps |
| 63 | +as well as notices from test runner. To get even more information with more technical details like error stacktraces, |
| 64 | +and global promises, or events use `--verbose` mode. |
| 65 | + |
| 66 | +``` |
| 67 | +GitHub -- |
| 68 | + register |
| 69 | + [1] Starting recording promises |
| 70 | + Emitted | test.before |
| 71 | + > WebDriverIO._before |
| 72 | + [1] Queued | hook WebDriverIO._before() |
| 73 | + [1] Queued | amOnPage: https://github.com |
| 74 | + Emitted | step.before (I am on page "https://github.com") |
| 75 | + • I am on page "https://github.com" |
| 76 | + Emitted | step.after (I am on page "https://github.com") |
| 77 | + Emitted | test.start ([object Object]) |
| 78 | +... |
| 79 | +``` |
| 80 | + |
| 81 | +Please use verbose output when reporting issues to GitHub. |
| 82 | + |
| 83 | +## XML |
| 84 | + |
| 85 | +Use default xunit reporter of Mocha to print xml reports. Provide `--reporter xunit` to get the report to screen. |
| 86 | +It is recommended to use more powerful [`mocha-junit-reporter`](https://www.npmjs.com/package/mocha-junit-reporter) package |
| 87 | +ot get better support for Jenkins CI. |
| 88 | + |
| 89 | +Install it via NPM (locally or globally, depending on CodeceptJS installation type): |
| 90 | + |
| 91 | +``` |
| 92 | +npm i mocha-junit-reporter |
| 93 | +``` |
| 94 | + |
| 95 | +Additional configuration should be added to `codecept.json` to print xml report to `output` directory: |
| 96 | + |
| 97 | +```json |
| 98 | + "mocha": { |
| 99 | + "reporterOptions": { |
| 100 | + "mochaFile": "output/result.xml" |
| 101 | + } |
| 102 | + }, |
| 103 | +``` |
| 104 | + |
| 105 | +Execute CodeceptJS with JUnit reporter: |
| 106 | + |
| 107 | +``` |
| 108 | +codeceptjs run --reporter mocha-junit-reporter |
| 109 | +``` |
| 110 | + |
| 111 | +Result will be located at `output/result.xml` file. |
| 112 | + |
| 113 | + |
| 114 | +## Html |
| 115 | + |
| 116 | +Best HTML reports could be prodused with [mochawesome](https://www.npmjs.com/package/mochawesome) reporter. |
| 117 | +Install it via NPM: |
| 118 | + |
| 119 | +``` |
| 120 | +npm i mochawesome |
| 121 | +``` |
| 122 | + |
| 123 | +Configure it to use `output` directory to print HTML reports: |
| 124 | + |
| 125 | +```json |
| 126 | + "mocha": { |
| 127 | + "reporterOptions": { |
| 128 | + "reportDir": "output" |
| 129 | + } |
| 130 | + }, |
| 131 | +``` |
| 132 | + |
| 133 | +Execute CodeceptJS with HTML reporter: |
| 134 | + |
| 135 | +``` |
| 136 | +codeceptjs run --reporter mochawesome. |
| 137 | +``` |
| 138 | + |
| 139 | +Result will be located at `output/index.html` file. |
| 140 | + |
0 commit comments