]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(tests): add afterEach cleanup to RemoteStartAuth test
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 27 Feb 2026 19:17:11 +0000 (20:17 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 27 Feb 2026 19:17:11 +0000 (20:17 +0100)
- 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

tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RemoteStartAuth.test.ts

index bc82ba994e93c236cf4ed8c6a993f380b6899305..5d4b9e5ed49e25e32d7750f48b5c38dc86ba6c2b 100644 (file)
@@ -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