Skip to content

Commit

Permalink
Handle seleniumArgs in config file ( #275 ) (#276)
Browse files Browse the repository at this point in the history
Handle seleniumArgs in config file ( #275 )
  • Loading branch information
jucrouzet committed Apr 24, 2017
1 parent 77c51ed commit b6377f2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion bin/selenium-standalone
Expand Up @@ -53,7 +53,11 @@ function parseCommandAndOptions(javaPath) {
// Merge default options, options from config file then command line options
options = merge({}, defaultConfig, configFromFile, options);

options.seleniumArgs = seleniumArgs;
if (seleniumArgs.length) {
options.seleniumArgs = seleniumArgs;
} else if (!Array.isArray(options.seleniumArgs)) {
options.seleniumArgs = [];
}
options.spawnOptions = {
stdio: 'inherit'
};
Expand Down
6 changes: 6 additions & 0 deletions test/cli-parameters.js
Expand Up @@ -122,6 +122,7 @@ describe('`selenium-standalone` command parameters', function() {
expect(parsed[1].version).to.be.equal('42');
expect(parsed[1].drivers.ie.version).to.be.equal(42);
expect(parsed[1].drivers.ie.baseURL).to.be.equal('http://www.google.fr');
expect(parsed[1].seleniumArgs).to.be.deep.equal([]);
});

it('are correctly parsed from a JS module config file', function() {
Expand All @@ -134,6 +135,7 @@ describe('`selenium-standalone` command parameters', function() {
expect(parsed[1].version).to.be.equal('42');
expect(parsed[1].drivers.ie.version).to.be.equal(42);
expect(parsed[1].drivers.ie.baseURL).to.be.equal('http://www.google.fr');
expect(parsed[1].seleniumArgs).to.be.deep.equal(['--test=1', '-flag']);
});

it('throws if config file is invalid', function() {
Expand Down Expand Up @@ -161,13 +163,17 @@ describe('`selenium-standalone` command parameters', function() {
'install',
'--config=' + path.join(__dirname, 'fixtures', 'config.valid.js'),
'--drivers.ie.version=43',
'--',
'--some=seleniumArgs'
]);

var parsed = parseCommandAndOptions('/somewhere');

expect(parsed[1].version).to.be.equal('42');
expect(parsed[1].drivers.ie.arch).to.be.equal(defaultValues.drivers.ie.arch);
expect(parsed[1].drivers.ie.version).to.be.equal('43');
expect(parsed[1].seleniumArgs).to.be.deep.equal(['--some=seleniumArgs']);
});

});
});
3 changes: 2 additions & 1 deletion test/fixtures/config.valid.js
Expand Up @@ -5,5 +5,6 @@ module.exports = {
version: 42,
baseURL: 'http://www.google.fr',
}
}
},
seleniumArgs: ['--test=1', '-flag'],
};

0 comments on commit b6377f2

Please sign in to comment.