diff --git a/spec/core/EnvSpec.js b/spec/core/EnvSpec.js index 72c8d979..821a3b27 100644 --- a/spec/core/EnvSpec.js +++ b/spec/core/EnvSpec.js @@ -133,6 +133,12 @@ describe('Env', function() { 'describe expects a function argument; received [object Function]' ); }); + + it('throws an error when it has no children', function() { + expect(function() { + env.describe('done method', function() {}); + }).toThrowError('describe with no children (describe() or it())'); + }); }); describe('#it', function() { diff --git a/spec/core/ExceptionsSpec.js b/spec/core/ExceptionsSpec.js index 538c682d..6dd4611b 100644 --- a/spec/core/ExceptionsSpec.js +++ b/spec/core/ExceptionsSpec.js @@ -30,7 +30,9 @@ describe('Exceptions:', function() { }); it('should handle exceptions thrown directly in top-level describe blocks and continue', function(done) { - var secondDescribe = jasmine.createSpy('second describe'); + var secondDescribe = jasmine.createSpy('second describe').and.callFake(function() { + env.it('is a test', function() {}); + }); env.describe('a suite that throws an exception', function() { env.it('is a test that should pass', function() { this.expect(true).toEqual(true); diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index 9c827b24..041e738e 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -1881,6 +1881,7 @@ describe("Env integration", function() { } catch(e) { exception = e; } + env.it('has a test', () => {}); }); var assertions = function() { @@ -1904,6 +1905,7 @@ describe("Env integration", function() { } catch(e) { exception = e; } + env.it('has a test', () => {}); }); var assertions = function() { @@ -1927,6 +1929,7 @@ describe("Env integration", function() { } catch(e) { exception = e; } + env.it('has a test', () => {}); }); var assertions = function() { diff --git a/src/core/Env.js b/src/core/Env.js index 43e4a8e7..f8a38ff7 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -843,6 +843,9 @@ getJasmineRequireObj().Env = function(j$) { suite.pend(); } addSpecsToSuite(suite, specDefinitions); + if (suite.parentSuite && !suite.children.length) { + throw new Error('describe with no children (describe() or it())'); + } return suite; };