@@ -38,19 +38,21 @@ test('async/await support', function (t) {
3838} ) ;
3939
4040test ( 'test title prefixes' , function ( t ) {
41- t . plan ( 5 ) ;
41+ t . plan ( 6 ) ;
4242
4343 var separator = ' ' + figures . pointerSmall + ' ' ;
4444 var files = [
4545 path . join ( __dirname , 'fixture/async-await.js' ) ,
4646 path . join ( __dirname , 'fixture/es2015.js' ) ,
47- path . join ( __dirname , 'fixture/generators.js' )
47+ path . join ( __dirname , 'fixture/generators.js' ) ,
48+ path . join ( __dirname , 'fixture/subdir/in-a-subdir.js' )
4849 ] ;
4950 var expected = [
5051 [ 'async-await' , 'async function' ] . join ( separator ) ,
5152 [ 'async-await' , 'arrow async function' ] . join ( separator ) ,
5253 [ 'es2015' , '[anonymous]' ] . join ( separator ) ,
53- [ 'generators' , 'generator function' ] . join ( separator )
54+ [ 'generators' , 'generator function' ] . join ( separator ) ,
55+ [ 'subdir' , 'in-a-subdir' , 'subdir' ] . join ( separator )
5456 ] ;
5557 var index ;
5658
@@ -64,8 +66,7 @@ test('test title prefixes', function (t) {
6466 } ) ;
6567
6668 api . on ( 'test' , function ( a ) {
67- var unnecessaryString = 'test' + separator + 'fixture' + separator ;
68- index = expected . indexOf ( a . title . replace ( unnecessaryString , '' ) ) ;
69+ index = expected . indexOf ( a . title ) ;
6970
7071 t . true ( index >= 0 ) ;
7172
@@ -88,7 +89,27 @@ test('display filename prefixes for failed test stack traces', function (t) {
8889 . then ( function ( ) {
8990 t . is ( api . passCount , 2 ) ;
9091 t . is ( api . failCount , 1 ) ;
91- t . match ( api . errors [ 0 ] . title , / t e s t \S f i x t u r e \S o n e - p a s s - o n e - f a i l \S t h i s i s a f a i l i n g t e s t / ) ;
92+ t . match ( api . errors [ 0 ] . title , / o n e - p a s s - o n e - f a i l \S t h i s i s a f a i l i n g t e s t / ) ;
93+ } ) ;
94+ } ) ;
95+
96+ // This is a seperate test because we can't ensure the order of the errors (to match them), and this is easier than
97+ // sorting.
98+ test ( 'display filename prefixes for failed test stack traces in subdirs' , function ( t ) {
99+ t . plan ( 3 ) ;
100+
101+ var files = [
102+ path . join ( __dirname , 'fixture/es2015.js' ) ,
103+ path . join ( __dirname , 'fixture/subdir/failing-subdir.js' )
104+ ] ;
105+
106+ var api = new Api ( files ) ;
107+
108+ api . run ( )
109+ . then ( function ( ) {
110+ t . is ( api . passCount , 1 ) ;
111+ t . is ( api . failCount , 1 ) ;
112+ t . match ( api . errors [ 0 ] . title , / s u b d i r \S f a i l i n g - s u b d i r \S s u b d i r f a i l / ) ;
92113 } ) ;
93114} ) ;
94115
0 commit comments