@@ -7,6 +7,7 @@ import debugModule from 'debug'
77const debug = debugModule ( 'codeceptjs:timeout' )
88import { TIMEOUT_ORDER , TimeoutError , TestTimeoutError , StepTimeoutError } from '../timeout.js'
99import { BeforeSuiteHook , AfterSuiteHook } from '../mocha/hooks.js'
10+ import { extractStepCode } from '../step.js'
1011
1112export default function ( ) {
1213 let timeout
@@ -122,15 +123,15 @@ export default function () {
122123 if ( typeof timeout !== 'number' ) return
123124
124125 if ( ! store . timeouts ) {
125- debug ( 'step' , ( step . code || ( typeof step . toCode === 'function' ? step . toCode ( ) : step . name ) ) . trim ( ) , 'timeout disabled' )
126+ debug ( 'step' , extractStepCode ( step ) , 'timeout disabled' )
126127 return
127128 }
128129
129130 if ( timeout < 0 ) {
130131 debug ( 'Previous steps timed out, setting timeout to 0.01s' )
131132 step . setTimeout ( 0.01 , TIMEOUT_ORDER . testOrSuite )
132133 } else {
133- debug ( `Setting timeout ${ timeout } ms for step ${ ( step . code || ( typeof step . toCode === 'function' ? step . toCode ( ) : step . name ) ) . trim ( ) } ` )
134+ debug ( `Setting timeout ${ timeout } ms for step ${ extractStepCode ( step ) } ` )
134135 step . setTimeout ( timeout , TIMEOUT_ORDER . testOrSuite )
135136 }
136137 } )
@@ -158,17 +159,17 @@ export default function () {
158159
159160 event . dispatcher . on ( event . step . finished , step => {
160161 if ( ! store . timeouts ) {
161- debug ( 'step' , ( step . code || ( typeof step . toCode === 'function' ? step . toCode ( ) : step . name ) ) . trim ( ) , 'timeout disabled' )
162+ debug ( 'step' , extractStepCode ( step ) , 'timeout disabled' )
162163 return
163164 }
164165
165166 if ( typeof timeout === 'number' ) debug ( 'Timeout' , timeout )
166167
167- debug ( `step ${ ( step . code || ( typeof step . toCode === 'function' ? step . toCode ( ) : step . name ) ) . trim ( ) } :${ step . status } duration` , step . duration )
168+ debug ( `step ${ extractStepCode ( step ) } :${ step . status } duration` , step . duration )
168169 if ( typeof timeout === 'number' && ! Number . isNaN ( timeout ) ) timeout -= step . duration
169170
170171 if ( typeof timeout === 'number' && timeout <= 0 && recorder . isRunning ( ) ) {
171- debug ( `step ${ ( step . code || ( typeof step . toCode === 'function' ? step . toCode ( ) : step . name ) ) . trim ( ) } timed out` )
172+ debug ( `step ${ extractStepCode ( step ) } timed out` )
172173 recorder . throw ( new TestTimeoutError ( currentTimeout ) )
173174 }
174175 } )
0 commit comments