diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index f752cdb9..bfb4d1b3 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1542,6 +1542,7 @@ getJasmineRequireObj().Env = function(j$) { * @since 2.0.0 */ this.topSuite = function() { + ensureNonParallel('topSuite'); return topSuite.metadata; }; diff --git a/spec/core/EnvSpec.js b/spec/core/EnvSpec.js index a2d25a9c..1b401f52 100644 --- a/spec/core/EnvSpec.js +++ b/spec/core/EnvSpec.js @@ -81,6 +81,19 @@ describe('Env', function() { ); expect(suite.children[1].children[1].children[0].children).toBeFalsy(); }); + + it('throws if called in parallel mode', function() { + env.setParallelLoadingState('helpers'); + check(); + env.setParallelLoadingState('specs'); + check(); + + function check() { + expect(function() { + env.topSuite(); + }).toThrowError("'topSuite' is not available in parallel mode"); + } + }); }); it('accepts its own current configureation', function() { diff --git a/src/core/Env.js b/src/core/Env.js index 6f6a1387..21dd0ef3 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -400,6 +400,7 @@ getJasmineRequireObj().Env = function(j$) { * @since 2.0.0 */ this.topSuite = function() { + ensureNonParallel('topSuite'); return topSuite.metadata; };