@@ -3,6 +3,7 @@ const output = require('../output')
33const recorder = require ( '../recorder' )
44const Config = require ( '../config' )
55const { timeouts } = require ( '../store' )
6+ const debug = require ( 'debug' ) ( 'codeceptjs:timeout' )
67const TIMEOUT_ORDER = require ( '../step' ) . TIMEOUT_ORDER
78
89module . exports = function ( ) {
@@ -20,6 +21,8 @@ module.exports = function () {
2021 suiteTimeout = [ ]
2122 let timeoutConfig = Config . get ( 'timeout' )
2223
24+ debug ( 'config:' , timeoutConfig || 'none' )
25+
2326 if ( timeoutConfig ) {
2427 if ( ! Number . isNaN ( + timeoutConfig ) ) {
2528 checkForSeconds ( timeoutConfig )
@@ -38,8 +41,10 @@ module.exports = function () {
3841 }
3942 }
4043
44+ debug ( 'current suite timeout:' , suite . totalTimeout || 'none' )
4145 if ( suite . totalTimeout ) suiteTimeout . push ( suite . totalTimeout )
4246 output . log ( `Timeouts: ${ suiteTimeout } ` )
47+ debug ( 'active timeouts' , suiteTimeout )
4348 } )
4449
4550 event . dispatcher . on ( event . test . before , test => {
@@ -81,8 +86,10 @@ module.exports = function () {
8186 if ( typeof timeout !== 'number' ) return
8287
8388 if ( timeout < 0 ) {
89+ debug ( 'Previous steps timed out, setting timeout to 0.01s' )
8490 step . setTimeout ( 0.01 , TIMEOUT_ORDER . testOrSuite )
8591 } else {
92+ debug ( `Setting timeout ${ timeout } ms for step ${ step . toCode ( ) . trim ( ) } ` )
8693 step . setTimeout ( timeout , TIMEOUT_ORDER . testOrSuite )
8794 }
8895 } )
@@ -91,7 +98,9 @@ module.exports = function () {
9198 if ( typeof timeout === 'number' && ! Number . isNaN ( timeout ) ) timeout -= step . duration
9299
93100 if ( typeof timeout === 'number' && timeout <= 0 && recorder . isRunning ( ) ) {
101+ debug ( `step ${ step . toCode ( ) . trim ( ) } timed out` )
94102 if ( currentTest && currentTest . callback ) {
103+ debug ( `Failing test ${ currentTest . title } with timeout ${ currentTimeout } s` )
95104 recorder . reset ( )
96105 // replace mocha timeout with custom timeout
97106 currentTest . timeout ( 0 )
0 commit comments