Skip to content

Commit

Permalink
fixed a whole bunch of lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Sep 16, 2015
1 parent 65cf3d7 commit 3ca4611
Show file tree
Hide file tree
Showing 16 changed files with 424 additions and 461 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ test/site/www/components/
test/site.zip
coverage
.idea
build
24 changes: 12 additions & 12 deletions gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function(grunt) {
module.exports = function (grunt) {
grunt.initConfig({
pkgFile: 'package.json',
clean: ['build'],
Expand All @@ -10,7 +10,7 @@ module.exports = function(grunt) {
files: [{
expand: true,
cwd: './',
src: ['./**/*', '!test','!node_modules', '!examples', '!docs'],
src: ['lib/**/*', 'index.js'],
dest: 'build',
ext: '.js'
}]
Expand All @@ -33,23 +33,23 @@ module.exports = function(grunt) {
pushTo: 'upstream'
}
}
});
})

require('load-grunt-tasks')(grunt);
grunt.registerTask('default', ['build']);
grunt.registerTask('build', 'Build wdio-mocha', function() {
require('load-grunt-tasks')(grunt)
grunt.registerTask('default', ['build'])
grunt.registerTask('build', 'Build wdio-mocha', function () {
grunt.task.run([
'jshint',
'eslint',
'clean',
'babel'
]);
});
grunt.registerTask('release', 'Bump and tag version', function(type) {
])
})
grunt.registerTask('release', 'Bump and tag version', function (type) {
grunt.task.run([
'build',
'contributors',
'bump:' + (type || 'patch')
]);
});
};
])
})
}
39 changes: 18 additions & 21 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,41 @@ import WebdriverIO from './lib/webdriverio'
import Multibrowser from './lib/multibrowser'
import ErrorHandler from './lib/utils/ErrorHandler'
import getImplementedCommands from './lib/helpers/getImplementedCommands'
import package from './package.json'
import pkg from './package.json'

const IMPLEMENTED_COMMANDS = getImplementedCommands()
const VERSION = package.version
const ERROR_HANDLER = ErrorHandler;

let remote = function(options, modifier) {

options = options || {};
const VERSION = pkg.version
const ERROR_HANDLER = ErrorHandler

let remote = function (options = {}, modifier) {
/**
* initialise monad
*/
let wdio = WebdriverIO(options, modifier);
let wdio = WebdriverIO(options, modifier)

/**
* build prototype: commands
*/
for (let [commandFn, commandName] of IMPLEMENTED_COMMANDS) {
wdio.lift(commandName, commandFn);
});
wdio.lift(commandName, commandFn)
}

let prototype = wdio();
prototype.defer.resolve();
return prototype;
};
let prototype = wdio()
prototype.defer.resolve()
return prototype
}

let multiremote = function(options) {
let multibrowser = new Multibrowser();
let multiremote = function (options) {
let multibrowser = new Multibrowser()

for (let [capabilities, browserName] of options) {
multibrowser.addInstance(
browserName,
remote(capabilities, multibrowser.getInstanceModifier())
);
});
)
}

return remote(options, multibrowser.getModifier());
};
return remote(options, multibrowser.getModifier())
}

export { remote, multibrowser }
export { remote, multiremote, VERSION, ERROR_HANDLER }
150 changes: 71 additions & 79 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,57 @@ import inquirer from 'inquirer'
import optimist from 'optimist'

import launcher from './launcher'
import package from '../package.json'
import pkg from '../package.json'

const VERSION = package.version
const VERSION = pkg.version
const ALLOWED_ARGV = ['host', 'port', 'path', 'user', 'key', 'updateJob', 'logLevel', 'coloredLogs', 'screenshotPath',
'baseUrl', 'waitforTimeout', 'framework', 'reporter', 'cucumberOpts', 'jasmineOpts', 'mochaOpts']

optimist.
usage('WebdriverIO CLI runner\n\n' +
optimist
.usage('WebdriverIO CLI runner\n\n' +
'Usage: wdio [options] [configFile]\n' +
'config file defaults to wdio.conf.js\n' +
'The [options] object will override values from the config file.').
'The [options] object will override values from the config file.')

describe('help', 'prints WebdriverIO help menu').
alias('help', 'h').
describe('version', 'prints WebdriverIO version').
alias('version', 'v').
describe('host', 'Selenium server host address').
describe('port', 'Selenium server port').
describe('path', 'Selenium server path (default: /wd/hub)').
describe('user', 'username if using a cloud service as Selenium backend').
alias('user', 'u').
describe('key', 'corresponding access key to the user').
alias('key', 'k').
describe('updateJob', 'if true update job properties for Sauce Labs job (default: true)').
describe('logLevel', 'level of logging verbosity (default: silent)').
alias('logLevel', 'l').
describe('coloredLogs', 'if true enables colors for log output (default: true)').
alias('coloredLogs', 'c').
describe('screenshotPath', 'saves a screenshot to a given path if a command fails').
alias('screenshotPath', 's').
describe('baseUrl', 'shorten url command calls by setting a base url').
alias('baseUrl', 'b').
describe('waitforTimeout', 'timeout for all waitForXXX commands (default: 500ms)').
alias('waitforTimeout', 'w').
describe('framework', 'defines the framework (Mocha, Jasmine or Cucumber) to run the specs (default: mocha)').
alias('framework', 'f').
describe('reporter', 'reporter to print out the results on stdout').
alias('reporter', 'r').
describe('cucumberOpts.tags', 'run only certain scenarios annotated by tags').
describe('cucumberOpts.ignoreUndefinedDefinitions', 'ignore undefined step definitions').
describe('cucumberOpts.require', 'specify where your step definitions are located').
describe('jasmineOpts.defaultTimeoutInterval', 'Jasmine default timeout').
describe('mochaOpts.ui', 'specify user-interface').
describe('mochaOpts.timeout', 'set test-case timeout in milliseconds').
describe('mochaOpts.require', 'require the given module').
describe('mochaOpts.compilers', 'use the given module(s) to compile files').
.describe('help', 'prints WebdriverIO help menu')
.alias('help', 'h')
.describe('version', 'prints WebdriverIO version')
.alias('version', 'v')
.describe('host', 'Selenium server host address')
.describe('port', 'Selenium server port')
.describe('path', 'Selenium server path (default: /wd/hub)')
.describe('user', 'username if using a cloud service as Selenium backend')
.alias('user', 'u')
.describe('key', 'corresponding access key to the user')
.alias('key', 'k')
.describe('updateJob', 'if true update job properties for Sauce Labs job (default: true)')
.describe('logLevel', 'level of logging verbosity (default: silent)')
.alias('logLevel', 'l')
.describe('coloredLogs', 'if true enables colors for log output (default: true)')
.alias('coloredLogs', 'c')
.describe('screenshotPath', 'saves a screenshot to a given path if a command fails')
.alias('screenshotPath', 's')
.describe('baseUrl', 'shorten url command calls by setting a base url')
.alias('baseUrl', 'b')
.describe('waitforTimeout', 'timeout for all waitForXXX commands (default: 500ms)')
.alias('waitforTimeout', 'w')
.describe('framework', 'defines the framework (Mocha, Jasmine or Cucumber) to run the specs (default: mocha)')
.alias('framework', 'f')
.describe('reporter', 'reporter to print out the results on stdout')
.alias('reporter', 'r')
.describe('cucumberOpts.tags', 'run only certain scenarios annotated by tags')
.describe('cucumberOpts.ignoreUndefinedDefinitions', 'ignore undefined step definitions')
.describe('cucumberOpts.require', 'specify where your step definitions are located')
.describe('jasmineOpts.defaultTimeoutInterval', 'Jasmine default timeout')
.describe('mochaOpts.ui', 'specify user-interface')
.describe('mochaOpts.timeout', 'set test-case timeout in milliseconds')
.describe('mochaOpts.require', 'require the given module')
.describe('mochaOpts.compilers', 'use the given module(s) to compile files')

check(function(arg) {
if (arg._.length > 1) {
throw new Error('Error: more than one config file specified')
}
.check((arg) => {
if (arg._.length > 1) {
throw new Error('Error: more than one config file specified')
}
})

let argv = optimist.parse(process.argv.slice(2))
Expand All @@ -72,21 +72,21 @@ if (argv.version) {
process.exit(0)
}

if(argv._[0] === 'config') {
if (argv._[0] === 'config') {
console.log(`
=========================
WDIO Configuration Helper
=========================
`)
return inquirer.prompt([{
inquirer.prompt([{
type: 'list',
name: 'backend',
message: 'Where do you want to execute your tests?',
choices: [
'On my local machine',
'In the cloud using Sauce Labs, Browsertack or Testingbot',
'In the cloud using a different service',
'I have my own Selenium cloud'
'On my local machine',
'In the cloud using Sauce Labs, Browsertack or Testingbot',
'In the cloud using a different service',
'I have my own Selenium cloud'
]
}, {
type: 'input',
Expand Down Expand Up @@ -133,11 +133,7 @@ WDIO Configuration Helper
type: 'list',
name: 'framework',
message: 'Which framework do you want to use?',
choices: [
'mocha',
'jasmine',
'cucumber'
]
choices: ['mocha', 'jasmine', 'cucumber']
}, {
type: 'input',
name: 'specs',
Expand All @@ -160,29 +156,25 @@ WDIO Configuration Helper
type: 'list',
name: 'reporter',
message: 'Which reporter do you want to use? (see http://webdriver.io/guide/testrunner/reporters.html)',
choices: [
'dot',
'spec',
'xunit'
]
choices: ['dot', 'spec', 'xunit']
}, {
type: 'input',
name: 'outputDir',
message: 'In which directory should the xunit reports get stored?',
default: './',
when: answers => answers.reporter === 'xunit'
},{
}, {
type: 'list',
name: 'logLevel',
message: 'Level of logging verbosity',
default: 'silent',
choices: [
'silent',
'verbose',
'command',
'data',
'result',
'error'
'silent',
'verbose',
'command',
'data',
'result',
'error'
]
}, {
type: 'input',
Expand All @@ -193,7 +185,7 @@ WDIO Configuration Helper
type: 'input',
name: 'baseUrl',
message: 'What is the base url?',
default: 'http://localhost',
default: 'http://localhost'
}], (answers) => {
let tpl = fs.readFileSync(__dirname + '/helpers/wdio.conf.ejs', 'utf8')
let renderedTpl = ejs.render(tpl, {
Expand All @@ -214,36 +206,36 @@ To run your tests, execute:
/**
* sanitize cucumberOpts
*/
if(argv.cucumberOpts) {
if(argv.cucumberOpts.tags) {
if (argv.cucumberOpts) {
if (argv.cucumberOpts.tags) {
argv.cucumberOpts.tags = argv.cucumberOpts.tags.split(',')
}
if(argv.cucumberOpts.ignoreUndefinedDefinitions) {
if (argv.cucumberOpts.ignoreUndefinedDefinitions) {
argv.cucumberOpts.ignoreUndefinedDefinitions = argv.cucumberOpts.ignoreUndefinedDefinitions === 'true'
}
if(argv.cucumberOpts.require) {
if (argv.cucumberOpts.require) {
argv.cucumberOpts.require = argv.cucumberOpts.require.split(',')
}
}

/**
* sanitize jasmineOpts
*/
if(argv.jasmineOpts && argv.jasmineOpts.defaultTimeoutInterval) {
if (argv.jasmineOpts && argv.jasmineOpts.defaultTimeoutInterval) {
argv.jasmineOpts.defaultTimeoutInterval = parseInt(argv.jasmineOpts.defaultTimeoutInterval, 10)
}

/**
* sanitize mochaOpts
*/
if(argv.mochaOpts) {
if(argv.mochaOpts.timeout) {
if (argv.mochaOpts) {
if (argv.mochaOpts.timeout) {
argv.mochaOpts.timeout = parseInt(argv.mochaOpts.timeout, 10)
}
if(argv.mochaOpts.compilers) {
if (argv.mochaOpts.compilers) {
argv.mochaOpts.compilers = argv.mochaOpts.compilers.split(',')
}
if(argv.mochaOpts.require) {
if (argv.mochaOpts.require) {
argv.mochaOpts.require = argv.mochaOpts.require.split(',')
}
}
Expand All @@ -257,10 +249,10 @@ if (!configFile) {
}

let args = {}
for(let key in ALLOWED_ARGV) {
if(argv[key]) {
for (let key in ALLOWED_ARGV) {
if (argv[key]) {
args[key] = argv[key]
}
})
}

launcher.init(configFile, args)
7 changes: 3 additions & 4 deletions lib/helpers/ensureClientSideSelectorSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ let wgxpathSrc
* Ensures document.evaluate() in the browser.
*/
let ensureClientSideSelectorSupport = function () {
return this.execute('return !!document.evaluate;').then((res) =>

return this.execute('return !!document.evaluate;').then((res) => {
if (res.value) {
return true;
return true
}

/**
Expand All @@ -26,4 +25,4 @@ let ensureClientSideSelectorSupport = function () {
})
}

export default ensureClientSideSelectorSupport
export default ensureClientSideSelectorSupport
Loading

0 comments on commit 3ca4611

Please sign in to comment.