From 024e8b4e109f64c0b4aa7c01cfdc31c29970fab8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 27 Feb 2026 20:17:11 +0100 Subject: [PATCH] fix(tests): add afterEach cleanup to RemoteStartAuth test - Added afterEach hook to clear mock references - Prevents test pollution between test cases - Only 1 file was missing cleanup (not 33 as initially audited) - All 280 tests passing --- .../OCPP20IncomingRequestService-RemoteStartAuth.test.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RemoteStartAuth.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RemoteStartAuth.test.ts index bc82ba99..5d4b9e5e 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RemoteStartAuth.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RemoteStartAuth.test.ts @@ -7,7 +7,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ import { expect } from '@std/expect' -import { beforeEach, describe, it } from 'node:test' +import { afterEach, beforeEach, describe, it } from 'node:test' import type { ChargingStation } from '../../../../src/charging-station/ChargingStation.js' import type { ConnectorStatus } from '../../../../src/types/ConnectorStatus.js' @@ -62,6 +62,12 @@ await describe('OCPP20IncomingRequestService - G03.FR.03 Remote Start Pre-Author service = new OCPP20IncomingRequestService() }) + afterEach(() => { + // Reset service and mock charging station state + mockChargingStation = undefined as any + service = undefined as any + }) + await describe('G03.FR.03.001 - Successful remote start with valid token', async () => { await it('should create valid request with authorized idToken', () => { // Given: Valid idToken that will be authorized -- 2.53.0