@@ -16,32 +16,38 @@ export function after(taskResult, backend) {
1616export function beforeEach ( taskResult , backend ) {
1717 const spec = Cypress . mocha . getRunner ( ) . suite . ctx . currentTest . parent . title ;
1818 const testName = Cypress . mocha . getRunner ( ) . suite . ctx . currentTest . title ;
19-
20- console . log ( `[ ${ new Date ( ) . toISOString ( ) } ] [ beforeEach] Starting for backend: ${ backend } `) ;
21- console . log ( `[ ${ new Date ( ) . toISOString ( ) } ] [ beforeEach] mockResponses:` , taskResult . data . mockResponses ) ;
22-
19+
20+ cy . task ( 'log' , `[ beforeEach] backend= ${ backend } spec=" ${ spec } " test=" ${ testName } " `) ;
21+ cy . task ( 'log' , `[ beforeEach] mockResponses= ${ String ( taskResult . data . mockResponses ) } ` ) ;
22+
2323 cy . task ( 'setupBackendTest' , {
2424 backend,
2525 ...taskResult . data ,
2626 spec,
2727 testName,
28+ } ) . then ( ( ) => {
29+ cy . task ( 'log' , '[beforeEach] setupBackendTest completed' ) ;
2830 } ) ;
2931
3032 if ( taskResult . data . mockResponses ) {
3133 const fixture = `${ spec } __${ testName } .json` ;
32- console . log ( 'loading fixture:' , fixture ) ;
33- cy . stubFetch ( { fixture } ) ;
34+ cy . task ( 'log' , `[beforeEach] Loading fixture: "${ fixture } "` ) ;
35+ cy . stubFetch ( { fixture } ) . then ( ( ) => {
36+ cy . task ( 'log' , '[beforeEach] stubFetch completed' ) ;
37+ } ) ;
38+ } else {
39+ cy . task ( 'log' , '[beforeEach] Skipping fixture load - mockResponses is false/undefined' ) ;
3440 }
3541
3642 // cy.clock(0, ['Date']) was hanging git-gateway tests after page load
3743 // Hypothesis: freezing time to 0 breaks app initialization during cy.visit()
3844 // Temporary fix: skip cy.clock for git-gateway, use default clock for others
3945 if ( backend !== 'git-gateway' ) {
40- console . log ( `[ ${ new Date ( ) . toISOString ( ) } ] [beforeEach] Setting clock to epoch 0 for non-git-gateway` ) ;
46+ cy . task ( 'log' , ' [beforeEach] Setting clock to epoch 0 for non-git-gateway' ) ;
4147 return cy . clock ( 0 , [ 'Date' ] ) ;
4248 }
43-
44- console . log ( `[ ${ new Date ( ) . toISOString ( ) } ] [beforeEach] Skipped clock for git-gateway` ) ;
49+
50+ cy . task ( 'log' , ' [beforeEach] Skipped clock for git-gateway' ) ;
4551}
4652
4753export function afterEach ( taskResult , backend ) {
@@ -59,12 +65,24 @@ export function afterEach(taskResult, backend) {
5965 const {
6066 suite : {
6167 ctx : {
62- currentTest : { state, _retries : retries , _currentRetry : currentRetry } ,
68+ currentTest : { state, _retries : retries , _currentRetry : currentRetry , err } ,
6369 } ,
6470 } ,
6571 } = Cypress . mocha . getRunner ( ) ;
72+
73+ cy . task (
74+ 'log' ,
75+ `[afterEach] backend=${ backend } test="${ testName } " state=${ state } retry=${ currentRetry } /${ retries } ` ,
76+ ) ;
77+ if ( state === 'failed' && err ?. message ) {
78+ cy . task ( 'log' , `[afterEach] failure: ${ err . message } ` ) ;
79+ }
80+
6681 if ( state === 'failed' && retries === currentRetry ) {
67- Cypress . runner . stop ( ) ;
82+ // Avoid deadlock in headless CI: runner.stop can leave recorded parallel runs hanging.
83+ if ( Cypress . config ( 'isInteractive' ) ) {
84+ Cypress . runner . stop ( ) ;
85+ }
6886 }
6987 }
7088}
0 commit comments