]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(test): remove redundant nested afterEach in Reset test causing Windows hang
authorJérôme Benoit <jerome.benoit@sap.com>
Sun, 1 Mar 2026 01:05:37 +0000 (02:05 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sun, 1 Mar 2026 01:05:37 +0000 (02:05 +0100)
The Reset test had nested describes (B11, B12) with their own afterEach
calling standardCleanup(), plus an outer afterEach calling mock.timers.reset()
then standardCleanup(). This caused mock.restoreAll() to be called twice
per test with timer reset in between - leaving MockTracker in inconsistent
state on Windows.

Also harmonize StationHelpers cleanup to use '= undefined' consistently
instead of mixing with 'delete'.

tests/charging-station/helpers/StationHelpers.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-Reset.test.ts

index 230fd8dce3122c8020cb00a7acde0d05d82266ea..ba0195c91c77e3ad9c6cbdc79e7d6ea5763fcc32 100644 (file)
@@ -216,7 +216,7 @@ export function cleanupChargingStation (station: ChargingStation): void {
     }
     if (connectorStatus.transactionTxUpdatedSetInterval != null) {
       clearInterval(connectorStatus.transactionTxUpdatedSetInterval)
-      delete connectorStatus.transactionTxUpdatedSetInterval
+      connectorStatus.transactionTxUpdatedSetInterval = undefined
     }
   }
 
@@ -229,7 +229,7 @@ export function cleanupChargingStation (station: ChargingStation): void {
       }
       if (connectorStatus.transactionTxUpdatedSetInterval != null) {
         clearInterval(connectorStatus.transactionTxUpdatedSetInterval)
-        delete connectorStatus.transactionTxUpdatedSetInterval
+        connectorStatus.transactionTxUpdatedSetInterval = undefined
       }
     }
   }
index 3a6a0b8bfc37b6f24d166c7b0c187bf0b1c1b65f..2269880605f00e101eb551f95c019a6f5567c1aa 100644 (file)
@@ -106,10 +106,6 @@ await describe('B11 & B12 - Reset', async () => {
       b11MockStation.reset = () => Promise.resolve()
     })
 
-    afterEach(() => {
-      standardCleanup()
-    })
-
     // FR: B11.FR.01
     await it('should handle Reset request with Immediate type when no transactions', async () => {
       const resetRequest: OCPP20ResetRequest = {
@@ -306,10 +302,6 @@ await describe('B11 & B12 - Reset', async () => {
       b12MockStation.reset = () => Promise.resolve()
     })
 
-    afterEach(() => {
-      standardCleanup()
-    })
-
     // FR: B12.FR.02
     await it('should handle immediate reset with active transactions', async () => {
       // Mock active transactions