npm.io
10.2.0 • Published 1 month ago

@wdio/spec-reporter

Licence
MIT
Version
10.2.0
Deps
5
Size
43 kB
Vulns
0
Weekly
0
Stars
9.9K

WDIO Spec Reporter

A WebdriverIO plugin to report in spec style.

Spec Reporter

Installation

The easiest way is to keep @wdio/spec-reporter as a devDependency in your package.json, via:

npm install @wdio/spec-reporter --save-dev

Instructions on how to install WebdriverIO can be found here.

Configuration

The following code shows the default wdio test runner configuration. Just add 'spec' as a reporter to the array.

// wdio.conf.js
module.exports = {
  // ...
  reporters: ['dot', 'spec'],
  // ...
};

Spec Reporter Options

symbols
Example
[
  "spec",
  {
    symbols: {
      passed: '[PASS]',
      failed: '[FAIL]',
    },
  },
]
Example
[
  "spec",
  {
    sauceLabsSharableLinks: false,
  },
]
onlyFailures
Example
[
  "spec",
  {
    onlyFailures: true,
  },
]
addConsoleLogs
```js [ "spec", { addConsoleLogs: true, }, ] ```
realtimeReporting
```js [ "spec", { realtimeReporting: true, }, ] ```
showPreface
```js [ "spec", { showPreface: false, }, ] ```

With it set to false you will see output as:

Running: loremipsum (v50) on Windows 10
Session ID: foobar

» foo/bar/loo.e2e.js
Foo test
   green ✓ foo
   green ✓ bar

» bar/foo/loo.e2e.js
Bar test
   green ✓ some test
   red ✖ a failed test
   red ✖ a failed test with no stack

and with true (default) each line will be prefixed with the preface:

[loremipsum 50 Windows 10 #0-0] Running: loremipsum (v50) on Windows 10
[loremipsum 50 Windows 10 #0-0] Session ID: foobar
[loremipsum 50 Windows 10 #0-0]
[loremipsum 50 Windows 10 #0-0] » foo/bar/loo.e2e.js
[loremipsum 50 Windows 10 #0-0] Foo test
[loremipsum 50 Windows 10 #0-0]    green ✓ foo
[loremipsum 50 Windows 10 #0-0]    green ✓ bar
[loremipsum 50 Windows 10 #0-0]
[loremipsum 50 Windows 10 #0-0] » bar/foo/loo.e2e.js
[loremipsum 50 Windows 10 #0-0] Bar test
[loremipsum 50 Windows 10 #0-0]    green ✓ some test
[loremipsum 50 Windows 10 #0-0]    red ✖ a failed test
[loremipsum 50 Windows 10 #0-0]    red ✖ a failed test with no stack
[loremipsum 50 Windows 10 #0-0]
color
```js [ "spec", { color: true, }, ] ```

Parallel mode

The reporter supports parallel mode (mochaOpts.parallelMode, cucumberOpts.parallelMode): each Mocha describe block and each Cucumber scenario is shown under its own parent, also when tests run at the same time.

Environment Options

There are certain options you can set through environment variables:

FORCE_COLOR

If set to true, e.g. via FORCE_COLOR=0 npx wdio run wdio.conf.js, all terminal coloring will be disabled.

Keywords