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) {