From 6626ce7690e1120c3b246eff7793a26cb038b091 Mon Sep 17 00:00:00 2001 From: mgiambalvo Date: Mon, 10 Oct 2016 13:46:59 -0700 Subject: [PATCH] fix(launcher) Ignore uncaught exceptions from webdriver. (#3608) --- lib/config.ts | 6 ++++++ lib/launcher.ts | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/lib/config.ts b/lib/config.ts index 49bb5b1b7..02d58001c 100644 --- a/lib/config.ts +++ b/lib/config.ts @@ -457,6 +457,12 @@ export interface Config { */ untrackOutstandingTimeouts?: boolean; + /** + * If set, Protractor will ignore uncaught exceptions instead of exiting + * without an error code. The exceptions will still be logged as warnings. + */ + ignoreUncaughtExceptions?: boolean; + // --------------------------------------------------------------------------- // ----- The test framework // -------------------------------------------------- diff --git a/lib/launcher.ts b/lib/launcher.ts index 54ea25362..325c12ab1 100644 --- a/lib/launcher.ts +++ b/lib/launcher.ts @@ -185,6 +185,13 @@ let initFn = function(configFile: string, additionalConfig: Config) { process.on('uncaughtException', (exc: (Error|string)) => { let e = (exc instanceof Error) ? exc : new Error(exc); + if (config.ignoreUncaughtExceptions) { + // This can be a sign of a bug in the test framework, that it may + // not be handling WebDriver errors properly. However, we don't + // want these errors to prevent running the tests. + logger.warn('Ignoring uncaught error ' + exc); + return; + } let errorCode = ErrorHandler.parseError(e); if (errorCode) {