diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index c64be6e3..ba0dd4a3 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -10017,6 +10017,8 @@ getJasmineRequireObj().SpyFactory = function(j$) { }; getJasmineRequireObj().SpyRegistry = function(j$) { + 'use strict'; + const spyOnMsg = j$.private.formatErrorMsg( '', 'spyOn(, )' @@ -10099,7 +10101,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) { }; } else { restoreStrategy = function() { - if (!delete obj[methodName]) { + try { + delete obj[methodName]; + // eslint-disable-next-line no-unused-vars + } catch (e) { obj[methodName] = originalMethod; } }; diff --git a/src/core/SpyRegistry.js b/src/core/SpyRegistry.js index b4d06b69..85723f33 100644 --- a/src/core/SpyRegistry.js +++ b/src/core/SpyRegistry.js @@ -1,4 +1,6 @@ getJasmineRequireObj().SpyRegistry = function(j$) { + 'use strict'; + const spyOnMsg = j$.private.formatErrorMsg( '', 'spyOn(, )' @@ -81,7 +83,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) { }; } else { restoreStrategy = function() { - if (!delete obj[methodName]) { + try { + delete obj[methodName]; + // eslint-disable-next-line no-unused-vars + } catch (e) { obj[methodName] = originalMethod; } };