diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 14143492..cb16a418 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1654,6 +1654,14 @@ getJasmineRequireObj().Env = function(j$) { * @return {Promise} */ this.execute = async function(runablesToRun) { + if (options.suppressLoadErrors) { + this.deprecated( + 'The suppressLoadErrors option is deprecated and will be removed ' + + 'in a future release.', + { ignoreRunnable: true, omitStackTrace: true } + ); + } + installGlobalErrors(); if (parallelLoadingState) { diff --git a/spec/core/EnvSpec.js b/spec/core/EnvSpec.js index f9f74ef3..c31af770 100644 --- a/spec/core/EnvSpec.js +++ b/spec/core/EnvSpec.js @@ -634,6 +634,10 @@ describe('Env', function() { }); describe('when constructed with suppressLoadErrors: true', function() { + beforeEach(function() { + spyOn(console, 'error'); // prevent deprecation from being logged + }); + it('does not install a global error handler until execute is called', function() { const globalErrors = jasmine.createSpyObj('globalErrors', [ 'install', diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index 8162472f..6388946f 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -2905,6 +2905,10 @@ describe('Env integration', function() { }); describe('If suppressLoadErrors: true was passed', function() { + beforeEach(function() { + spyOn(console, 'error'); // prevent deprecation from being logged + }); + it('does not install a global error handler during loading', async function() { const originalOnerror = jasmine.createSpy('original onerror'); const global = { @@ -2943,6 +2947,24 @@ describe('Env integration', function() { expect(e.failedExpectations).toEqual([]); expect(originalOnerror).toHaveBeenCalledWith('Uncaught Error: ENOCHEESE'); }); + + it('emits a deprecation warning', async function() { + env.cleanup_(); + env = new jasmineUnderTest.Env({ suppressLoadErrors: true }); + const reporter = jasmine.createSpyObj('reporter', [ + 'jasmineDone', + 'suiteDone', + 'specDone' + ]); + + env.addReporter(reporter); + await env.execute(); + + const e = reporter.jasmineDone.calls.argsFor(0)[0]; + expect(e.deprecationWarnings[0].message).toMatch( + /^The suppressLoadErrors option is deprecated and will be removed in a future release/ + ); + }); }); describe('Overall status in the jasmineDone event', function() { diff --git a/src/core/Env.js b/src/core/Env.js index b922cb26..7c2f4536 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -518,6 +518,14 @@ getJasmineRequireObj().Env = function(j$) { * @return {Promise} */ this.execute = async function(runablesToRun) { + if (options.suppressLoadErrors) { + this.deprecated( + 'The suppressLoadErrors option is deprecated and will be removed ' + + 'in a future release.', + { ignoreRunnable: true, omitStackTrace: true } + ); + } + installGlobalErrors(); if (parallelLoadingState) {