From: Jérôme Benoit Date: Sun, 1 Mar 2026 01:05:37 +0000 (+0100) Subject: fix(test): remove redundant nested afterEach in Reset test causing Windows hang X-Git-Tag: ocpp-server@v3.0.0~48 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=019e3a27c08d720ec2b23462719262ee11371809;p=e-mobility-charging-stations-simulator.git fix(test): remove redundant nested afterEach in Reset test causing Windows hang 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'. --- diff --git a/tests/charging-station/helpers/StationHelpers.ts b/tests/charging-station/helpers/StationHelpers.ts index 230fd8dc..ba0195c9 100644 --- a/tests/charging-station/helpers/StationHelpers.ts +++ b/tests/charging-station/helpers/StationHelpers.ts @@ -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 } } } diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-Reset.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-Reset.test.ts index 3a6a0b8b..22698806 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-Reset.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-Reset.test.ts @@ -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