From 43ce27057eb0b86b5659f8eb49a50e1752d33d4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Tyczy=C5=84ski?= Date: Wed, 19 Jul 2023 20:04:34 +0200 Subject: [PATCH] fix: Fix clobbering of arguments in custom configurations (#50) Properly merge arrays when custom configuration is used, so i.e. ChromeHeadless now can be extended with additional args: ```js customLaunchers: { 'ChromeHeadlessNoSandbox': { base: 'ChromeHeadless', config: { 'goog:chromeOptions': { args: [ '--no-sandbox', // before we had to pass other args because merge wasn't working properly // '--headless', // '--disable-gpu', // '--disable-dev-shm-usage', ], }, }, }, }, ``` --- index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 3008b16..8a1b3d7 100644 --- a/index.js +++ b/index.js @@ -68,8 +68,14 @@ const LocalWebDriverBase = function(baseBrowserDecorator, args, logger) { log.debug('config:', JSON.stringify(config)); - const extraSpecs = - _.merge(this.constructor.EXTRA_WEBDRIVER_SPECS, args.config); + const extraSpecs = _.mergeWith( + this.constructor.EXTRA_WEBDRIVER_SPECS, + args.config, + (objValue, srcValue) => { + if (Array.isArray(objValue)) { + return objValue.concat(srcValue); + } + }); log.debug('extraSpecs:', extraSpecs); // These names ("browser" and "spec") are needed for compatibility with