diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 2ec4dda3..3135ef51 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1983,6 +1983,13 @@ getJasmineRequireObj().Env = function(j$) { suite.pend(); } addSpecsToSuite(suite, specDefinitions); + if (suite.parentSuite && !suite.children.length) { + this.deprecated( + 'describe with no children (describe() or it()) is ' + + 'deprecated and will be removed in a future version of Jasmine. ' + + 'Please either remove the describe or add children to it.' + ); + } return suite; }; diff --git a/spec/core/EnvSpec.js b/spec/core/EnvSpec.js index 1e50b0b8..ea6f4bc2 100644 --- a/spec/core/EnvSpec.js +++ b/spec/core/EnvSpec.js @@ -141,11 +141,24 @@ describe('Env', function() { ); expect(function() { - env.describe('fn arg', function() {}); + env.describe('fn arg', function() { + env.it('has a spec', function() {}); + }); }).not.toThrowError( 'describe expects a function argument; received [object Function]' ); }); + + it('logs a deprecation when it has no children', function() { + spyOn(env, 'deprecated'); + env.describe('no children', function() {}); + expect(env.deprecated).toHaveBeenCalledWith( + 'describe with no children' + + ' (describe() or it()) is deprecated and will be removed in a future ' + + 'version of Jasmine. Please either remove the describe or add ' + + 'children to it.' + ); + }); }); describe('#it', function() { diff --git a/spec/core/ExceptionsSpec.js b/spec/core/ExceptionsSpec.js index c5e65754..a040f6a9 100644 --- a/spec/core/ExceptionsSpec.js +++ b/spec/core/ExceptionsSpec.js @@ -34,7 +34,11 @@ 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('has 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 bd35817c..e032120a 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -1863,6 +1863,7 @@ describe("Env integration", function() { } catch(e) { exception = e; } + env.it('has a test', function() {}); }); var assertions = function() { @@ -1885,6 +1886,7 @@ describe("Env integration", function() { } catch(e) { exception = e; } + env.it('has a test', function() {}); }); var assertions = function() { @@ -1907,6 +1909,7 @@ describe("Env integration", function() { } catch(e) { exception = e; } + env.it('has a test', function() {}); }); var assertions = function() { diff --git a/src/core/Env.js b/src/core/Env.js index eeeece86..39fa276b 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -1034,6 +1034,13 @@ getJasmineRequireObj().Env = function(j$) { suite.pend(); } addSpecsToSuite(suite, specDefinitions); + if (suite.parentSuite && !suite.children.length) { + this.deprecated( + 'describe with no children (describe() or it()) is ' + + 'deprecated and will be removed in a future version of Jasmine. ' + + 'Please either remove the describe or add children to it.' + ); + } return suite; };