Skip to content

Commit e0ab9bd

Browse files
committed
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 angular#4050
1 parent 237593a commit e0ab9bd

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/cli.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,17 @@ if (argv.exclude) {
200200
argv.exclude = processFilePatterns_(<string>argv.exclude);
201201
}
202202

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

0 commit comments

Comments
 (0)