diff --git a/src/node/Launcher.ts b/src/node/Launcher.ts index fad95bdc45fe6..64b15e6b22973 100644 --- a/src/node/Launcher.ts +++ b/src/node/Launcher.ts @@ -71,8 +71,8 @@ class ChromeLauncher implements ProductLauncher { ignoreDefaultArgs = false, args = [], dumpio = false, - channel = null, - executablePath = null, + channel, + executablePath, pipe = false, env = process.env, handleSIGINT = true, @@ -83,7 +83,7 @@ class ChromeLauncher implements ProductLauncher { slowMo = 0, timeout = 30000, waitForInitialPage = true, - debuggingPort = null, + debuggingPort, } = options; const chromeArguments = []; @@ -133,26 +133,9 @@ class ChromeLauncher implements ProductLauncher { isTempUserDataDir = false; - let chromeExecutable = executablePath; - - if (channel) { - // executablePath is detected by channel, so it should not be specified by user. - assert( - typeof executablePath === 'string', - '`executablePath` must not be specified when `channel` is given.' - ); - - chromeExecutable = executablePathForChannel(channel); - } else if (!executablePath) { - const { missingText, executablePath } = resolveExecutablePath(this); - if (missingText) throw new Error(missingText); - chromeExecutable = executablePath; - } - - if (!chromeExecutable) { - throw new Error('chromeExecutable is not found.'); - } - + const chromeExecutable = !executablePath + ? this.executablePath(channel) + : executablePath; const usePipe = chromeArguments.includes('--remote-debugging-pipe'); const runner = new BrowserRunner( this.product, @@ -262,7 +245,11 @@ class ChromeLauncher implements ProductLauncher { if (channel) { return executablePathForChannel(channel); } else { - return resolveExecutablePath(this).executablePath; + const results = resolveExecutablePath(this); + if (results.missingText) { + throw new Error(results.missingText); + } + return results.executablePath; } }