@@ -6,7 +6,7 @@ var runMocha = helpers.runMocha;
66var runMochaJSON = helpers . runMochaJSON ;
77
88describe ( 'nested test detection' , function ( ) {
9- var nestedTestErrorMessage = 'Nested tests are not allowed ' ;
9+ var nestedTestErrorMessage = 'Nested test ".*" detected inside ' ;
1010
1111 describe ( 'BDD interface' , function ( ) {
1212 it ( 'should fail when nested tests are detected' , function ( done ) {
@@ -20,7 +20,7 @@ describe('nested test detection', function () {
2020 return done ( err ) ;
2121 }
2222 expect ( res , 'to have failed with output' , new RegExp ( nestedTestErrorMessage ) ) ;
23- expect ( res , 'to have failed with output' , / i n n e r n e s t e d t e s t .* d e t e c t e d i n s i d e t e s t .* o u t e r t e s t / ) ;
23+ expect ( res , 'to have failed with output' , / i n n e r n e s t e d t e s t .* d e t e c t e d i n s i d e .* o u t e r t e s t / ) ;
2424 done ( ) ;
2525 } ,
2626 spawnOpts
@@ -53,7 +53,7 @@ describe('nested test detection', function () {
5353 return done ( err ) ;
5454 }
5555 expect ( res , 'to have failed with output' , new RegExp ( nestedTestErrorMessage ) ) ;
56- expect ( res , 'to have failed with output' , / i n n e r n e s t e d t e s t .* d e t e c t e d i n s i d e t e s t .* o u t e r t e s t / ) ;
56+ expect ( res , 'to have failed with output' , / i n n e r n e s t e d t e s t .* d e t e c t e d i n s i d e .* o u t e r t e s t / ) ;
5757 done ( ) ;
5858 } ,
5959 spawnOpts
@@ -86,7 +86,7 @@ describe('nested test detection', function () {
8686 return done ( err ) ;
8787 }
8888 expect ( res , 'to have failed with output' , new RegExp ( nestedTestErrorMessage ) ) ;
89- expect ( res , 'to have failed with output' , / n e s t e d i n s y n c .* d e t e c t e d i n s i d e t e s t .* s y n c n e s t e d t e s t / ) ;
89+ expect ( res , 'to have failed with output' , / n e s t e d i n s y n c .* d e t e c t e d i n s i d e .* s y n c n e s t e d t e s t / ) ;
9090 done ( ) ;
9191 } ,
9292 spawnOpts
@@ -104,7 +104,7 @@ describe('nested test detection', function () {
104104 return done ( err ) ;
105105 }
106106 expect ( res , 'to have failed with output' , new RegExp ( nestedTestErrorMessage ) ) ;
107- expect ( res , 'to have failed with output' , / n e s t e d i n a s y n c .* d e t e c t e d i n s i d e t e s t .* a s y n c \/ a w a i t n e s t e d t e s t / ) ;
107+ expect ( res , 'to have failed with output' , / n e s t e d i n a s y n c .* d e t e c t e d i n s i d e .* a s y n c \/ a w a i t n e s t e d t e s t / ) ;
108108 done ( ) ;
109109 } ,
110110 spawnOpts
@@ -122,7 +122,7 @@ describe('nested test detection', function () {
122122 return done ( err ) ;
123123 }
124124 expect ( res , 'to have failed with output' , new RegExp ( nestedTestErrorMessage ) ) ;
125- expect ( res , 'to have failed with output' , / U n c a u g h t .* n e s t e d i n c a l l b a c k .* d e t e c t e d i n s i d e t e s t .* c a l l b a c k n e s t e d t e s t / ) ;
125+ expect ( res , 'to have failed with output' , / U n c a u g h t .* n e s t e d i n c a l l b a c k .* d e t e c t e d i n s i d e .* c a l l b a c k n e s t e d t e s t / ) ;
126126 done ( ) ;
127127 } ,
128128 spawnOpts
@@ -140,7 +140,27 @@ describe('nested test detection', function () {
140140 return done ( err ) ;
141141 }
142142 expect ( res , 'to have failed with output' , new RegExp ( nestedTestErrorMessage ) ) ;
143- expect ( res , 'to have failed with output' , / U n c a u g h t .* n e s t e d i n p r o m i s e .* d e t e c t e d i n s i d e t e s t .* p r o m i s e n e s t e d t e s t / ) ;
143+ expect ( res , 'to have failed with output' , / U n c a u g h t .* n e s t e d i n p r o m i s e .* d e t e c t e d i n s i d e .* p r o m i s e n e s t e d t e s t / ) ;
144+ done ( ) ;
145+ } ,
146+ spawnOpts
147+ ) ;
148+ } ) ;
149+ } ) ;
150+
151+ describe ( 'hook nested tests' , function ( ) {
152+ it ( 'should fail when nested tests are detected inside hooks' , function ( done ) {
153+ var fixture = path . join ( 'nested-tests' , 'bdd-hook-nested' ) ;
154+ var spawnOpts = { stdio : 'pipe' } ;
155+ runMocha (
156+ fixture ,
157+ [ '--ui' , 'bdd' ] ,
158+ function ( err , res ) {
159+ if ( err ) {
160+ return done ( err ) ;
161+ }
162+ expect ( res , 'to have failed with output' , new RegExp ( nestedTestErrorMessage ) ) ;
163+ expect ( res , 'to have failed with output' , / n e s t e d t e s t i n b e f o r e h o o k .* d e t e c t e d i n s i d e .* " b e f o r e a l l " h o o k / ) ;
144164 done ( ) ;
145165 } ,
146166 spawnOpts
@@ -160,7 +180,7 @@ describe('nested test detection', function () {
160180 return done ( err ) ;
161181 }
162182 expect ( res , 'to have failed with output' , / E r r o r : N e s t e d t e s t " i n n e r n e s t e d t e s t " / ) ;
163- expect ( res , 'to have failed with output' , / d e t e c t e d i n s i d e t e s t " o u t e r t e s t w i t h n e s t e d t e s t " / ) ;
183+ expect ( res , 'to have failed with output' , / d e t e c t e d i n s i d e " o u t e r t e s t w i t h n e s t e d t e s t " / ) ;
164184 expect ( res , 'to have failed with output' , / c r e a t e U n s u p p o r t e d E r r o r / ) ;
165185 done ( ) ;
166186 } ,
0 commit comments