1- const { expect } = require ( 'chai' )
2- const event = require ( '../../lib/event' )
3- const Config = require ( '../../lib/config' )
4- const enhancedGlobalRetry = require ( '../../lib/listener/enhancedGlobalRetry' )
5- const enhancedRetryFailedStep = require ( '../../lib/plugin/enhancedRetryFailedStep' )
6- const retryCoordinator = require ( '../../lib/retryCoordinator' )
7- const store = require ( '../../lib/store' )
8- const recorder = require ( '../../lib/recorder' )
9- const { createTest } = require ( '../../lib/mocha/test' )
10- const { createSuite } = require ( '../../lib/mocha/suite' )
11- const MochaSuite = require ( 'mocha/lib/suite' )
1+ import { expect } from 'chai'
2+ import event from '../../lib/event.js'
3+ import Config from '../../lib/config.js'
4+ import enhancedGlobalRetry from '../../lib/listener/enhancedGlobalRetry.js'
5+ import enhancedRetryFailedStep from '../../lib/plugin/enhancedRetryFailedStep.js'
6+ import * as retryCoordinator from '../../lib/retryCoordinator.js'
7+ import store from '../../lib/store.js'
8+ import recorder from '../../lib/recorder.js'
9+ import { createTest } from '../../lib/mocha/test.js'
10+ import { createSuite } from '../../lib/mocha/suite.js'
11+ import MochaSuite from 'mocha/lib/suite.js'
12+ import output from '../../lib/output.js'
1213
1314describe ( 'Enhanced Retry Mechanisms' , function ( ) {
1415 let originalConfig
1516 let capturedLogs
17+ let originalLog
1618
1719 beforeEach ( function ( ) {
1820 // Capture original configuration
1921 originalConfig = Config . get ( )
2022
2123 // Setup log capturing
2224 capturedLogs = [ ]
23- const originalLog = require ( '../../lib/ output' ) . log
24- require ( '../../lib/ output' ) . log = message => {
25+ originalLog = output . log
26+ output . log = message => {
2527 capturedLogs . push ( message )
2628 // Comment out to reduce noise: originalLog(message)
2729 }
@@ -34,6 +36,11 @@ describe('Enhanced Retry Mechanisms', function () {
3436 } )
3537
3638 afterEach ( function ( ) {
39+ // Restore original log
40+ if ( originalLog ) {
41+ output . log = originalLog
42+ }
43+
3744 // Restore original configuration
3845 Config . create ( originalConfig )
3946
@@ -67,8 +74,8 @@ describe('Enhanced Retry Mechanisms', function () {
6774 event . dispatcher . emit ( event . test . before , test )
6875
6976 // Check that priority information is tracked
70- expect ( suite . opts . retryPriority ) . to . equal ( enhancedGlobalRetry . RETRY_PRIORITIES . FEATURE_CONFIG )
71- expect ( test . opts . retryPriority ) . to . equal ( enhancedGlobalRetry . RETRY_PRIORITIES . SCENARIO_CONFIG )
77+ expect ( suite . opts . retryPriority ) . to . equal ( retryCoordinator . RETRY_PRIORITIES . FEATURE_CONFIG )
78+ expect ( test . opts . retryPriority ) . to . equal ( retryCoordinator . RETRY_PRIORITIES . SCENARIO_CONFIG )
7279
7380 // Check logging includes enhanced information
7481 const globalRetryLogs = capturedLogs . filter ( log => log . includes ( '[Global Retry]' ) )
@@ -89,10 +96,10 @@ describe('Enhanced Retry Mechanisms', function () {
8996 // First set by global retry
9097 event . dispatcher . emit ( event . test . before , test )
9198 expect ( test . retries ( ) ) . to . equal ( 2 )
92- expect ( test . opts . retryPriority ) . to . equal ( enhancedGlobalRetry . RETRY_PRIORITIES . SCENARIO_CONFIG )
99+ expect ( test . opts . retryPriority ) . to . equal ( retryCoordinator . RETRY_PRIORITIES . SCENARIO_CONFIG )
93100
94101 // Simulate a higher priority mechanism (like manual retry)
95- test . opts . retryPriority = enhancedGlobalRetry . RETRY_PRIORITIES . MANUAL_STEP
102+ test . opts . retryPriority = retryCoordinator . RETRY_PRIORITIES . MANUAL_STEP
96103 test . retries ( 1 ) // Manual override
97104
98105 // Global retry should not override higher priority
0 commit comments