File tree 2 files changed +21
-7
lines changed
2 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,9 @@ const ICON_FAIL = chalk.red('\u2718');
14
14
const ICON_WARN = chalk . bold . yellow ( '!' ) ;
15
15
const ICON_RETRY = chalk . yellow ( '⟳' ) ;
16
16
17
- const getSkipReason = ( test , skipReason ) => test && ( getSkipReason ( test . parent ) || test . skipReason ) || skipReason ;
18
-
19
- const getRelativeFilePath = ( file ) => {
20
- return file ? path . relative ( process . cwd ( ) , file ) : 'undefined' ;
21
- } ;
17
+ const getSkipReason = ( test ) => test && ( getSkipReason ( test . parent ) || test . skipReason ) ;
18
+ const getFilePath = ( test ) => test && test . file || getFilePath ( test . parent ) ;
19
+ const getRelativeFilePath = ( file ) => file ? path . relative ( process . cwd ( ) , file ) : undefined ;
22
20
23
21
module . exports = class FlatReporter {
24
22
constructor ( ) {
@@ -146,12 +144,13 @@ module.exports = class FlatReporter {
146
144
}
147
145
148
146
static _getTestInfo ( test ) {
147
+ const file = getFilePath ( test ) ;
148
+
149
149
return {
150
150
title : test . fullTitle ( ) ,
151
151
browser : test . browserId ,
152
- file : getRelativeFilePath ( test . file ) ,
152
+ file : getRelativeFilePath ( file ) ,
153
153
error : test . err ? ( test . err . stack || test . err . message || test . err ) : undefined
154
154
} ;
155
155
}
156
-
157
156
} ;
Original file line number Diff line number Diff line change @@ -228,6 +228,21 @@ describe('Flat reporter', () => {
228
228
assert . include ( stdout , test . file ) ;
229
229
} ) ;
230
230
231
+ it ( 'should log path to file of failed hook' , ( ) => {
232
+ test = mkTestStub_ ( {
233
+ file : null ,
234
+ parent : {
235
+ file : 'path-to-test'
236
+ }
237
+ } ) ;
238
+
239
+ sandbox . stub ( path , 'relative' ) . returns ( `relative/${ test . parent . file } ` ) ;
240
+
241
+ emit ( RunnerEvents . TEST_FAIL , test ) ;
242
+
243
+ assert . include ( stdout , 'relative/path-to-test' ) ;
244
+ } ) ;
245
+
231
246
it ( 'should log browser of failed suite' , ( ) => {
232
247
test = mkTestStub_ ( {
233
248
browserId : 'bro1'
You can’t perform that action at this time.
0 commit comments