From 019e3a27c08d720ec2b23462719262ee11371809 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 1 Mar 2026 02:05:37 +0100 Subject: [PATCH] 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'. --- tests/charging-station/helpers/StationHelpers.ts | 4 ++-- .../ocpp/2.0/OCPP20IncomingRequestService-Reset.test.ts | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) 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 -- 2.53.0