Skip to content

Commit

Permalink
fix service configuration for wdio6
Browse files Browse the repository at this point in the history
  • Loading branch information
amitzur committed Jun 15, 2020
1 parent af8b7f8 commit 50aaa5f
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions packages/eyes-webdriverio-5/src/EyesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const DEFAULT_VIEWPORT = {

class EyesService {
constructor(config) {
const runner =
config && config.eyes && config.eyes.useVisualGrid
? new VisualGridRunner(config.eyes.concurrency)
: undefined
this._eyesConfig = getServiceConfig(config)
const runner = this._eyesConfig.useVisualGrid
? new VisualGridRunner(this._eyesConfig.concurrency)
: undefined
this._eyes = new Eyes(runner)
this._eyes.getBaseAgentId = () =>
runner
Expand All @@ -39,7 +39,6 @@ class EyesService {
*/
// eslint-disable-next-line
beforeSession(config, capabilities, specs) {
this._eyesConfig = config.eyes
if (this._eyesConfig) {
this._eyes.setConfiguration(this._eyesConfig)
this._appName = this._eyes.getConfiguration().getAppName()
Expand Down Expand Up @@ -170,4 +169,17 @@ class EyesService {
}
}

function getServiceConfig(config) {
let wdioVersion = 6
try {
const wdioPkgJson = require('webdriverio/package.json') // eslint-disable-line node/no-extraneous-require
wdioVersion = Number(wdioPkgJson.version.split('.', 1)[0])
if (isNaN(wdioVersion)) {
wdioVersion = 6
}
} catch (ex) {}

return wdioVersion >= 6 ? config : config.eyes
}

module.exports = EyesService

0 comments on commit 50aaa5f

Please sign in to comment.