Skip to content

Commit

Permalink
Merge pull request #23 from fijijavis/v5_conversion
Browse files Browse the repository at this point in the history
V5 conversion
  • Loading branch information
fijijavis authored Apr 22, 2019
2 parents ef148d9 + 83ca22c commit f6fdfa0
Show file tree
Hide file tree
Showing 21 changed files with 2,858 additions and 1,679 deletions.
4 changes: 0 additions & 4 deletions .babelrc

This file was deleted.

2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"browser": true
},
"env": {
"mocha": true
"jest": true
}
}
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
node_modules/
npm-debug.log
.vscode/*
wdiomochawesome.json
build/
screenshots/
phantom.log
wdio-mochawesome-report/
mochawesome-report/
yarn-error.log
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
node_modules/
npm-debug.log
.vscode/*
wdiomochawesome.json
test/
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: node_js

node_js:
- 10.5.0

install:
- yarn --frozen-lockfile

script:
- yarn lint
- yarn test
241 changes: 67 additions & 174 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,83 @@ WDIO JSON Reporter

> A WebdriverIO plugin. Report results in json format.
This project was derived from the 'wdio-junit-reporter' found [here](https://github.com/webdriverio/wdio-junit-reporter)

## WDIO Version Compatibility

There are breaking changes between WDIO v4 and v5 with how custom reporters work. The chart below shows the versions of this reporter and their WDIO compatibility version.

| WDIO Json Reporter | WDIO |
| ------------------ | ---- |
| ^0.4.0 | v4 |
| ^1.0.0 | v5 |



# WDIO v5 Compatibility

## Installation

The easiest way is to keep `wdio-json-reporter` as a dependency in your `package.json`.
* NPM
```bash
npm install wdio-json-reporter --save-dev
```

* Yarn
```bash
yarn add wdio-json-reporter --dev
```

## Configuration

### Results to STDOUT
```js
reporters: [
'dot',
['json',{ stdout: true }]
],
```

### Results to File
```js
reporters: [
'dot',
['json',{
outputDir: './Results'
}]
],
```

```json
{
"dependencies": {
"wdio-json-reporter": "~0.1.0"
}
}
### Results to File with custom file name
```js
reporters: [
'dot',
['json',{
outputDir: './Results',
outputFileFormat: function(opts) {
return `results-${opts.cid}.${opts.capabilities}.json`
}
}]
],
```

You can simply do it by:

# WDIO v4 Compatibility

## Installation

* NPM
```bash
npm install wdio-json-reporter --save
npm install wdio-json-reporter@^0.4.0 --save-dev
```

Instructions on how to install `WebdriverIO` can be found [here](http://webdriver.io/guide/getstarted/install.html).
* Yarn
```bash
yarn add wdio-json-reporter@^0.4.0 --dev
```

## Configuration

### Standard
Following code shows the default wdio test runner configuration. Just add `'json'` as reporter
to the array. To get some output during the test you can run the [WDIO Dot Reporter](https://github.com/webdriverio/wdio-dot-reporter) and the WDIO JSON Reporter at the same time:

Expand All @@ -37,13 +89,13 @@ module.exports = {
// ...
reporters: ['dot', 'json'],
reporterOptions: {
outputDir: './'
outputDir: './Results'
},
// ...
};
```

It's also possible to combine all the resulting jsons into one.
### Single Results File

```js
// wdio.conf.js
Expand All @@ -58,8 +110,7 @@ module.exports = {
};
```

Another option is to configure the resulting filename of the JSON, if combined is set to false or not set a number is added after the file name: wdio-results-0-1.json etc.

### Custom File Name

```js
// wdio.conf.js
Expand All @@ -74,7 +125,7 @@ module.exports = {
};
```

You can also choose to send the reporter output to stdout instead of writing to a file:
### STDOUT

```js
// wdio.conf.js
Expand Down Expand Up @@ -104,162 +155,4 @@ module.exports = {



## Sample Output
```
{
"start": "2016-05-04T13:05:59.006Z",
"end": "2016-05-04T13:06:15.539Z",
"capabilities": {
"platform": "VISTA",
"browserName": "chrome"
},
"host": "127.0.0.1",
"port": 4444,
"baseUrl": "http://www.some-application.com",
"framework": "mocha",
"mochaOpts": {
"timeout": 10000,
"ui": "tdd",
"grep": "@Smoke"
},
"state": {
"passed": 2,
"failed": 2,
"skipped": 0
}
"suites": [
{
"name": "sample test suite number 1",
"duration": 12572,
"start": "2016-05-04T13:06:01.701Z",
"end": "2016-05-04T13:06:14.273Z",
"tests": [
{
"name": "@Smoke-Sample test number 1",
"start": "2016-05-04T13:06:01.701Z",
"end": "2016-05-04T13:06:08.162Z",
"duration": 6461,
"state": "pass"
},
{
"name": "@Smoke-Sample test number 2",
"start": "2016-05-04T13:06:08.471Z",
"end": "2016-05-04T13:06:13.845Z",
"duration": 5374,
"state": "fail",
"error": "element (#not-a-real-element) still not visible after 5000ms",
"errorType": "CommandError",
"standardError": "CommandError: element (#not-a-real-element) still not visible after 5000ms\n at Object.Future.wait (/node_modules/fibers/future.js:449:15)\n at Object.waitForVisible (/node_modules/wdio-sync/build/index.js:345:27)\n at Object.create.searchForStores.value (/PageObjects/some.page.js:15:17)\n at Context.<anonymous> (/Tests/sample.spec.js:64:25)\n at /node_modules/wdio-sync/build/index.js:579:24\n - - - - -\n at elements(\"#not-a-real-element\") - isVisible.js:49:17\n at isVisible(\"#not-a-real-element\") - waitForVisible.js:40:22"
}
],
"hooks": [
{
"start": "2016-09-08T12:50:51.829Z",
"end": "2016-09-08T12:50:54.475Z",
"duration": 2646,
"title": "\"before each\" hook",
"associatedSuite": "sample test suite number 1",
"associatedTest": "@Smoke-Sample test number 1"
},
{
"start": "2016-09-08T12:50:57.672Z",
"end": "2016-09-08T12:50:57.672Z",
"duration": 0,
"title": "\"after each\" hook",
"associatedSuite": "sample test suite number 1",
"associatedTest": "@Smoke-Sample test number 1"
},
{
"start": "2016-09-08T12:51:51.829Z",
"end": "2016-09-08T12:51:54.475Z",
"duration": 2646,
"title": "\"before each\" hook",
"associatedSuite": "sample test suite number 1",
"associatedTest": "@Smoke-Sample test number 2"
},
{
"start": "2016-09-08T12:51:57.672Z",
"end": "2016-09-08T12:51:57.672Z",
"duration": 0,
"title": "\"after each\" hook",
"associatedSuite": "sample test suite number 1",
"associatedTest": "@Smoke-Sample test number 2"
},
{
"start": "2016-09-08T12:50:57.672Z",
"end": "2016-09-08T12:50:57.672Z",
"duration": 0,
"title": "\"after all\" hook",
"associatedSuite": "sample test suite number 1"
}
]
},
{
"name": "sample test suite number 2",
"duration": 25987,
"start": "2016-05-04T13:16:01.701Z",
"end": "2016-05-04T13:16:24.273Z",
"tests": [
{
"name": "@Smoke-Sample test number 3",
"start": "2016-05-04T13:06:11.701Z",
"end": "2016-05-04T13:06:18.162Z",
"duration": 6461,
"state": "pass"
},
{
"name": "@Smoke-Sample test number 4",
"start": "2016-05-04T13:06:18.471Z",
"end": "2016-05-04T13:06:23.845Z",
"duration": 5374,
"state": "fail",
"error": "element (#not-a-real-element) still not visible after 5000ms",
"errorType": "CommandError",
"standardError": "CommandError: element (#not-a-real-element) still not visible after 5000ms\n at Object.Future.wait (/node_modules/fibers/future.js:449:15)\n at Object.waitForVisible (/node_modules/wdio-sync/build/index.js:345:27)\n at Object.create.searchForStores.value (/PageObjects/some.page.js:15:17)\n at Context.<anonymous> (/Tests/sample.spec.js:64:25)\n at /node_modules/wdio-sync/build/index.js:579:24\n - - - - -\n at elements(\"#not-a-real-element\") - isVisible.js:49:17\n at isVisible(\"#not-a-real-element\") - waitForVisible.js:40:22"
}
],
"hooks": [
{
"start": "2016-09-08T12:50:57.672Z",
"end": "2016-09-08T12:50:57.672Z",
"duration": 0,
"title": "\"after all\" hook",
"associatedSuite": "sample test suite number 2"
}
]
}
]
}
```

### Cucumber framework support
When using cucumber framework the output contains, in addition to the other data, an information about "tags":
```
...
"suites": [
{
"name": "sample test suite number 1",
"tags":[
"@sample-tag1",
"@sample-tag2"
],
"duration": 12572,
"start": "2016-05-04T13:06:01.701Z",
"end": "2016-05-04T13:06:14.273Z",
"tests": [
{
"name": "@Smoke-Sample test number 1",
"tags":[
"@sample-tag"
],
"start": "2016-05-04T13:06:01.701Z",
"end": "2016-05-04T13:06:08.162Z",
"duration": 6461,
"state": "pass"
},
...
```

----

For more information on WebdriverIO see the [homepage](http://webdriver.io).
Loading

0 comments on commit f6fdfa0

Please sign in to comment.