From 07dc39aabd4e66d144f5490ae3f324c59f067297 Mon Sep 17 00:00:00 2001 From: rafaelcalpena Date: Sat, 15 Jul 2017 23:19:25 -0300 Subject: [PATCH 1/4] throw error when adding nested it specs --- packages/jest-jasmine2/src/jasmine/Env.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/jest-jasmine2/src/jasmine/Env.js b/packages/jest-jasmine2/src/jasmine/Env.js index 2a0ad062806e..d670602e6838 100644 --- a/packages/jest-jasmine2/src/jasmine/Env.js +++ b/packages/jest-jasmine2/src/jasmine/Env.js @@ -388,6 +388,14 @@ module.exports = function(j$) { if (currentDeclarationSuite.markedPending) { spec.pend(); } + if (currentSpec !== null) { + throw new Error( + 'Test ' + + spec.description + + 'cannot run because it is nested in ' + + currentSpec.description + ); + } currentDeclarationSuite.addChild(spec); return spec; }; From 5e758f61491b180ca9c47303bf07f946e828e3cc Mon Sep 17 00:00:00 2001 From: rafaelcalpena Date: Sat, 15 Jul 2017 23:27:30 -0300 Subject: [PATCH 2/4] add comment --- packages/jest-jasmine2/src/jasmine/Env.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/jest-jasmine2/src/jasmine/Env.js b/packages/jest-jasmine2/src/jasmine/Env.js index d670602e6838..3c85276511d5 100644 --- a/packages/jest-jasmine2/src/jasmine/Env.js +++ b/packages/jest-jasmine2/src/jasmine/Env.js @@ -388,6 +388,10 @@ module.exports = function(j$) { if (currentDeclarationSuite.markedPending) { spec.pend(); } + + /* When a test is defined inside another, jasmine will not run it + This check throws an error to warn the developer about + the edge-case */ if (currentSpec !== null) { throw new Error( 'Test ' + From 8651d581ac79d7060787b1724b89926d0eb24a40 Mon Sep 17 00:00:00 2001 From: rafaelcalpena Date: Sat, 15 Jul 2017 23:31:53 -0300 Subject: [PATCH 3/4] improve error message --- packages/jest-jasmine2/src/jasmine/Env.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/jest-jasmine2/src/jasmine/Env.js b/packages/jest-jasmine2/src/jasmine/Env.js index 3c85276511d5..7359176ae6e0 100644 --- a/packages/jest-jasmine2/src/jasmine/Env.js +++ b/packages/jest-jasmine2/src/jasmine/Env.js @@ -394,10 +394,11 @@ module.exports = function(j$) { the edge-case */ if (currentSpec !== null) { throw new Error( - 'Test ' + + 'Test `' + spec.description + - 'cannot run because it is nested in ' + - currentSpec.description + '` cannot run because it is nested in `' + + currentSpec.description + + '`', ); } currentDeclarationSuite.addChild(spec); From b19293a8d93ab16737d8eab8cb4e0d7f7cd5c5d4 Mon Sep 17 00:00:00 2001 From: Christoph Nakazawa Date: Thu, 24 Aug 2017 13:17:16 +0100 Subject: [PATCH 4/4] Update Env.js --- packages/jest-jasmine2/src/jasmine/Env.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/jest-jasmine2/src/jasmine/Env.js b/packages/jest-jasmine2/src/jasmine/Env.js index 7359176ae6e0..abd2b3bdd30f 100644 --- a/packages/jest-jasmine2/src/jasmine/Env.js +++ b/packages/jest-jasmine2/src/jasmine/Env.js @@ -389,16 +389,15 @@ module.exports = function(j$) { spec.pend(); } - /* When a test is defined inside another, jasmine will not run it - This check throws an error to warn the developer about - the edge-case */ + // When a test is defined inside another, jasmine will not run it. + // This check throws an error to warn the user about the edge-case. if (currentSpec !== null) { throw new Error( - 'Test `' + + 'Tests cannot be nested. Test `' + spec.description + - '` cannot run because it is nested in `' + + '` cannot run because it is nested within `' + currentSpec.description + - '`', + '`.', ); } currentDeclarationSuite.addChild(spec);