Skip to content

Commit

Permalink
Adding outputDir to standalone (#3583)
Browse files Browse the repository at this point in the history
## Proposed changes

[//]: # (Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.)
Added outputDir option for standalone (no testrunner) 
## Types of changes

[//]: # (What types of changes does your code introduce to WebdriverIO?)
[//]: # (_Put an `x` in the boxes that apply_)

- [ ] Bugfix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

## Checklist

[//]: # (_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._)

- [X] I have read the [CONTRIBUTING](https://github.com/webdriverio/webdriverio/blob/master/CONTRIBUTING.md) doc
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have added necessary documentation (if appropriate)

## Further comments

[//]: # (If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...)

### Reviewers: @webdriverio/technical-committee
  • Loading branch information
Gilad-Shnoor authored and christian-bromann committed Feb 21, 2019
1 parent 9e03559 commit 792f089
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
14 changes: 8 additions & 6 deletions docs/Options.md
Expand Up @@ -66,6 +66,14 @@ Type: `String`<br>
Default: `info`<br>
Options: `trace` | `debug` | `info` | `warn` | `error` | `silent`

### outputDir
Directory to store all testrunner log files including reporter logs and `wdio` logs. If not set all logs are streamed to stdout. Since most reporters are made to log to stdout it is recommended to only use this option for specific reporters where it makes more sense to push report into a file (e.g. junit reporter).

When running in standalone mode the only log generated by webdriverio will be the `wdio` log.

Type: `String`<br>
Default: `null`

### connectionRetryTimeout
Timeout for any request to the Selenium server

Expand Down Expand Up @@ -108,12 +116,6 @@ Like the capabilities section described above, except with the option to specifi
Type: `Object`|`Object[]`<br>
Default: `[{ maxInstances: 5, browserName: 'firefox' }]`

### outputDir
Directory to store all testrunner log files including reporter logs and `wdio` logs. If not set all logs are streamed to stdout. Since most reporters are made to log to stdout it is recommended to only use this option for specific reporters where it makes more sense to push report into a file (e.g. junit reporter).

Type: `String`<br>
Default: `null`

### baseUrl
Shorten `url` command calls by setting a base url. If your `url` parameter starts with `/`, the base url gets prepended, not including the path portion of your baseUrl. If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url gets prepended directly.

Expand Down
5 changes: 5 additions & 0 deletions packages/webdriverio/src/index.js
@@ -1,3 +1,4 @@
import path from 'path'
import WebDriver from 'webdriver'
import { validateConfig, wrapCommand, runFnInFiberContext, detectBackend } from '@wdio/config'

Expand Down Expand Up @@ -27,6 +28,10 @@ export const remote = async function (params = {}, remoteModifier) {
params = Object.assign({}, detectBackend(params), params)
}

if(params.outputDir){
process.env.WDIO_LOG_PATH = path.join(params.outputDir, 'wdio.log')
}

const prototype = getPrototype('browser')
const instance = await WebDriver.newSession(params, modifier, prototype, wrapCommand)

Expand Down
7 changes: 7 additions & 0 deletions packages/webdriverio/tests/module.test.js
@@ -1,3 +1,4 @@
import path from 'path'
import { detectBackend } from '@wdio/config'

import { remote, multiremote } from '../src'
Expand Down Expand Up @@ -56,6 +57,12 @@ describe('WebdriverIO module interface', () => {
await remote({ user: 'foo', key: 'bar', capabilities: {} })
expect(detectBackend).toBeCalled()
})

it('should set process.env.WDIO_LOG_PATH if outputDir is set in the options', async()=>{
let testDirPath = './logs'
await remote({outputDir: testDirPath, capabilities: { browserName: 'firefox' } })
expect(process.env.WDIO_LOG_PATH).toEqual(path.join(testDirPath, 'wdio.log'))
})
})

describe('multiremote', () => {
Expand Down

0 comments on commit 792f089

Please sign in to comment.