Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit 1250278

Browse files
NickTomlinheathkit
authored andcommitted
fix(cli): Correctly parse list chromeOptions
Chromedriver requires that certain options always be passed as an array. Optimist passes --single-option as a string instead of an array which is invalid. This ensures that we always pass an array, even if a single option is passed via the cli. Fixes #4050
1 parent a655d45 commit 1250278

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/cli.ts

+11
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ if (argv.exclude) {
203203
argv.exclude = processFilePatterns_(<string>argv.exclude);
204204
}
205205

206+
if (argv.capabilities && argv.capabilities.chromeOptions) {
207+
// ensure that single options (which optimist parses as a string)
208+
// are passed in an array in chromeOptions when required:
209+
// https://sites.google.com/a/chromium.org/chromedriver/capabilities#TOC-chromeOptions-object
210+
['args', 'extensions', 'excludeSwitches', 'windowTypes'].forEach((key) => {
211+
if (typeof argv.capabilities.chromeOptions[key] === 'string') {
212+
argv.capabilities.chromeOptions[key] = [argv.capabilities.chromeOptions[key]];
213+
}
214+
});
215+
}
216+
206217
// Use default configuration, if it exists.
207218
let configFile: string = argv._[0];
208219
if (!configFile) {

0 commit comments

Comments
 (0)