From 1d62504534aa05aeee2f0bdf095c588dcf63bc96 Mon Sep 17 00:00:00 2001 From: Gregg Van Hove Date: Wed, 26 Apr 2017 13:54:07 -0700 Subject: [PATCH] Check for `process.listeners` as well, for GlobalErrors - Fixes #1333 --- lib/jasmine-core/jasmine.js | 6 +++--- src/core/GlobalErrors.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index e570230c..2f7c1bcf 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1068,7 +1068,7 @@ getJasmineRequireObj().Env = function(j$) { this.it = function(description, fn, timeout) { // it() sometimes doesn't have a fn argument, so only check the type if // it's given. - if (arguments.length > 1) { + if (arguments.length > 1 && typeof fn !== 'undefined') { ensureIsFunction(fn, 'it'); } var spec = specFactory(description, fn, currentDeclarationSuite, timeout); @@ -1082,7 +1082,7 @@ getJasmineRequireObj().Env = function(j$) { this.xit = function(description, fn, timeout) { // xit(), like it(), doesn't always have a fn argument, so only check the // type when needed. - if (arguments.length > 1) { + if (arguments.length > 1 && typeof fn !== 'undefined') { ensureIsFunction(fn, 'xit'); } var spec = this.it.apply(this, arguments); @@ -2174,7 +2174,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { this.uninstall = function noop() {}; this.install = function install() { - if (global.process && j$.isFunction_(global.process.on)) { + if (global.process && global.process.listeners && j$.isFunction_(global.process.on)) { var originalHandlers = global.process.listeners('uncaughtException'); global.process.removeAllListeners('uncaughtException'); global.process.on('uncaughtException', onerror); diff --git a/src/core/GlobalErrors.js b/src/core/GlobalErrors.js index 599941cc..4f253329 100644 --- a/src/core/GlobalErrors.js +++ b/src/core/GlobalErrors.js @@ -11,7 +11,7 @@ getJasmineRequireObj().GlobalErrors = function(j$) { this.uninstall = function noop() {}; this.install = function install() { - if (global.process && j$.isFunction_(global.process.on)) { + if (global.process && global.process.listeners && j$.isFunction_(global.process.on)) { var originalHandlers = global.process.listeners('uncaughtException'); global.process.removeAllListeners('uncaughtException'); global.process.on('uncaughtException', onerror);