]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
refactor(tests): standardize cleanup and strict equality
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 28 Feb 2026 17:43:48 +0000 (18:43 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 28 Feb 2026 17:43:48 +0000 (18:43 +0100)
- Migrate 15 test files to use standardCleanup() from TestLifecycleHelpers
- Replace all 27 .toEqual() with .toStrictEqual() across 10 files
- Fix import path in OCPP20CertificateManager.test.ts

This completes P0 (cleanup standardization) and P1 (strict equality)
from the test audit. All 291 tests pass.

22 files changed:
tests/charging-station/ChargingStation-Configuration.test.ts
tests/charging-station/ChargingStation-Connectors.test.ts
tests/charging-station/ChargingStation-Lifecycle.test.ts
tests/charging-station/ChargingStation-Resilience.test.ts
tests/charging-station/ChargingStation-Transactions.test.ts
tests/charging-station/ChargingStation.test.ts
tests/charging-station/ocpp/2.0/OCPP20CertificateManager.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetBaseReport.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-GetVariables.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RemoteStartAuth.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStartTransaction.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts
tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-SetVariables.test.ts
tests/charging-station/ocpp/2.0/OCPP20RequestService-HeartBeat.test.ts
tests/charging-station/ocpp/2.0/OCPP20RequestService-NotifyReport.test.ts
tests/charging-station/ocpp/auth/cache/InMemoryAuthCache.test.ts
tests/charging-station/ocpp/auth/factories/AuthComponentFactory.test.ts
tests/charging-station/ocpp/auth/services/OCPPAuthServiceFactory.test.ts
tests/charging-station/ocpp/auth/services/OCPPAuthServiceImpl.test.ts
tests/charging-station/ocpp/auth/utils/AuthHelpers.test.ts
tests/charging-station/ui-server/UIHttpServer.test.ts
tests/utils/Utils.test.ts

index 4f9db71246a891605718e8e984b9294e2f53c2e3..83de22598865bb1c1aae7677c5380a690d854fe8 100644 (file)
@@ -8,7 +8,7 @@ import { afterEach, beforeEach, describe, it } from 'node:test'
 import type { ChargingStation } from '../../src/charging-station/ChargingStation.js'
 
 import { AvailabilityType, RegistrationStatusEnumType } from '../../src/types/index.js'
-import { withMockTimers } from '../helpers/TestLifecycleHelpers.js'
+import { standardCleanup, withMockTimers } from '../helpers/TestLifecycleHelpers.js'
 import { cleanupChargingStation, createMockChargingStation } from './ChargingStationTestUtils.js'
 
 // Alias for tests that reference createRealChargingStation
@@ -24,6 +24,7 @@ await describe('ChargingStation Configuration Management', async () => {
       station = undefined
     })
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
@@ -121,6 +122,7 @@ await describe('ChargingStation Configuration Management', async () => {
       station = undefined
     })
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
@@ -247,6 +249,7 @@ await describe('ChargingStation Configuration Management', async () => {
       station = undefined
     })
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
@@ -428,6 +431,7 @@ await describe('ChargingStation Configuration Management', async () => {
       station = undefined
     })
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
@@ -561,7 +565,7 @@ await describe('ChargingStation Configuration Management', async () => {
       // Assert
       const parsed = mocks.webSocket.getSentMessagesAsJson()
       expect(parsed.length).toBe(1)
-      expect(parsed[0]).toEqual([2, 'uuid-1', 'Heartbeat', {}])
+      expect(parsed[0]).toStrictEqual([2, 'uuid-1', 'Heartbeat', {}])
     })
 
     await it('should clear captured messages via clearMessages()', () => {
@@ -750,6 +754,7 @@ await describe('ChargingStation Configuration Management', async () => {
       station = undefined
     })
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
index 227b9399f65c9b86ecbccc384cfda81f0ee842a9..4b8591cba79752e7c3c38b5507926c34105dcab2 100644 (file)
@@ -8,6 +8,7 @@ import { afterEach, beforeEach, describe, it } from 'node:test'
 import type { ChargingStation } from '../../src/charging-station/ChargingStation.js'
 
 import { RegistrationStatusEnumType } from '../../src/types/index.js'
+import { standardCleanup } from '../helpers/TestLifecycleHelpers.js'
 import { cleanupChargingStation, createMockChargingStation } from './ChargingStationTestUtils.js'
 
 // Alias for tests that reference createRealChargingStation
@@ -22,6 +23,7 @@ await describe('ChargingStation Connector and EVSE State', async () => {
     })
 
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
@@ -103,6 +105,7 @@ await describe('ChargingStation Connector and EVSE State', async () => {
       station = undefined
     })
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
@@ -133,6 +136,7 @@ await describe('ChargingStation Connector and EVSE State', async () => {
       station = undefined
     })
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
@@ -162,6 +166,7 @@ await describe('ChargingStation Connector and EVSE State', async () => {
       station = undefined
     })
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
@@ -258,6 +263,7 @@ await describe('ChargingStation Connector and EVSE State', async () => {
       station = undefined
     })
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
@@ -362,6 +368,7 @@ await describe('ChargingStation Connector and EVSE State', async () => {
       station = undefined
     })
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
index e42648d64fdc0a1c0949b5e6293c572fa4549f0b..5672cafead408cfb2f3bfd55062b3e0035d39dbe 100644 (file)
@@ -7,6 +7,7 @@ import { afterEach, beforeEach, describe, it } from 'node:test'
 
 import type { ChargingStation } from '../../src/charging-station/ChargingStation.js'
 
+import { standardCleanup } from '../helpers/TestLifecycleHelpers.js'
 import { cleanupChargingStation, createMockChargingStation } from './ChargingStationTestUtils.js'
 
 await describe('ChargingStation Lifecycle', async () => {
@@ -17,6 +18,7 @@ await describe('ChargingStation Lifecycle', async () => {
     })
 
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
@@ -168,6 +170,7 @@ await describe('ChargingStation Lifecycle', async () => {
     })
 
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
index ee431b9554a3a968870ff0e459ce267edc8e8a29..e4756de0cb23a5a2f52343b3776f67d9785197f4 100644 (file)
@@ -8,6 +8,7 @@ import { afterEach, beforeEach, describe, it } from 'node:test'
 import type { ChargingStation } from '../../src/charging-station/ChargingStation.js'
 
 import { RegistrationStatusEnumType } from '../../src/types/index.js'
+import { standardCleanup } from '../helpers/TestLifecycleHelpers.js'
 import { cleanupChargingStation, createMockChargingStation } from './ChargingStationTestUtils.js'
 
 await describe('ChargingStation Error Recovery and Resilience', async () => {
@@ -18,6 +19,7 @@ await describe('ChargingStation Error Recovery and Resilience', async () => {
   })
 
   afterEach(() => {
+    standardCleanup()
     // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
     if (station != null) {
       cleanupChargingStation(station)
@@ -283,6 +285,7 @@ await describe('ChargingStation Message Buffering', async () => {
   })
 
   afterEach(() => {
+    standardCleanup()
     // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
     if (station != null) {
       cleanupChargingStation(station)
index 32d15a19d6666602ce4638ac25894288a46da6e8..af1f30359c28923eab9b3ed05ab4f4fd854e69b5 100644 (file)
@@ -7,7 +7,7 @@ import { afterEach, beforeEach, describe, it } from 'node:test'
 
 import type { ChargingStation } from '../../src/charging-station/ChargingStation.js'
 
-import { withMockTimers } from '../helpers/TestLifecycleHelpers.js'
+import { standardCleanup, withMockTimers } from '../helpers/TestLifecycleHelpers.js'
 import { cleanupChargingStation, createMockChargingStation } from './ChargingStationTestUtils.js'
 
 await describe('ChargingStation Transaction Management', async () => {
@@ -18,6 +18,7 @@ await describe('ChargingStation Transaction Management', async () => {
       station = undefined
     })
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
@@ -174,6 +175,7 @@ await describe('ChargingStation Transaction Management', async () => {
       station = undefined
     })
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
@@ -277,6 +279,7 @@ await describe('ChargingStation Transaction Management', async () => {
       station = undefined
     })
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
@@ -441,6 +444,7 @@ await describe('ChargingStation Transaction Management', async () => {
       station = undefined
     })
     afterEach(() => {
+      standardCleanup()
       if (station != null) {
         cleanupChargingStation(station)
       }
index 2f2a1901b6057d29143c258d9b4bf4caf59250a4..ce58592c59803e6e7e929957234ede4284bd5d91 100644 (file)
@@ -241,7 +241,7 @@ await describe('ChargingStation Integration Tests', async () => {
 
       // Store some data in cache
       mocks1.idTagsCache.setIdTags('test-file.json', ['tag1', 'tag2'])
-      expect(mocks1.idTagsCache.getIdTags('test-file.json')).toEqual(['tag1', 'tag2'])
+      expect(mocks1.idTagsCache.getIdTags('test-file.json')).toStrictEqual(['tag1', 'tag2'])
 
       // Cleanup first station
       cleanupChargingStation(result1.station)
index 4ddeb1b64c2f8103f708cebd6236beec74b4f245..9e01913c32d3a3c456df5528dbb682a15e361604 100644 (file)
@@ -13,6 +13,7 @@ import {
   HashAlgorithmEnumType,
   InstallCertificateUseEnumType,
 } from '../../../../src/types/index.js'
+import { standardCleanup } from '../../../helpers/TestLifecycleHelpers.js'
 
 const TEST_STATION_HASH_ID = 'test-station-hash-12345'
 const TEST_CERT_TYPE = InstallCertificateUseEnumType.CSMSRootCertificate
@@ -61,6 +62,7 @@ await describe('I02-I04 - ISO15118 Certificate Management', async () => {
       force: true,
       recursive: true,
     })
+    standardCleanup()
   })
 
   await describe('storeCertificate', async () => {
index af451bcac6e3d321dccd49ff3b1288c39b57d63e..96c2a544cfa5606b7f6b1f689c82f812aef0c31f 100644 (file)
@@ -27,6 +27,7 @@ import {
 } from '../../../../src/types/index.js'
 import { StandardParametersKey } from '../../../../src/types/ocpp/Configuration.js'
 import { Constants } from '../../../../src/utils/index.js'
+import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.js'
 import { createChargingStation } from '../../../ChargingStationFactory.js'
 import {
   TEST_CHARGE_POINT_MODEL,
@@ -65,6 +66,7 @@ await describe('B07 - Get Base Report', async () => {
 
   // Reset singleton state after each test to ensure test isolation
   afterEach(() => {
+    standardCleanup()
     OCPP20VariableManager.getInstance().resetRuntimeOverrides()
   })
 
@@ -109,7 +111,7 @@ await describe('B07 - Get Base Report', async () => {
       const types =
         heartbeatEntry.variableAttribute?.map((a: { type?: string; value?: string }) => a.type) ??
         []
-      expect(types).toEqual([AttributeEnumType.Actual])
+      expect(types).toStrictEqual([AttributeEnumType.Actual])
     }
     // Boolean variable (AuthorizeRemoteStart) should only include Actual
     const authorizeRemoteStartEntry = reportData.find(
@@ -123,7 +125,7 @@ await describe('B07 - Get Base Report', async () => {
         authorizeRemoteStartEntry.variableAttribute?.map(
           (a: { type?: string; value?: string }) => a.type
         ) ?? []
-      expect(types).toEqual([AttributeEnumType.Actual])
+      expect(types).toStrictEqual([AttributeEnumType.Actual])
     }
   })
 
index 196006f879093246e26b7938e6d95e34dddb07d9..12fd1116f2e57a01a8cc822841ac3a670fd2f517 100644 (file)
@@ -21,6 +21,7 @@ import {
   ReasonCodeEnumType,
 } from '../../../../src/types/index.js'
 import { Constants } from '../../../../src/utils/index.js'
+import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.js'
 import { createChargingStation } from '../../../ChargingStationFactory.js'
 import {
   TEST_CHARGING_STATION_BASE_NAME,
@@ -55,6 +56,7 @@ await describe('B06 - Get Variables', async () => {
 
   // Reset singleton state after each test to ensure test isolation
   afterEach(() => {
+    standardCleanup()
     OCPP20VariableManager.getInstance().resetRuntimeOverrides()
   })
 
index c42f6d37aafa51c1d5e5e047b9ecfe26c34b2962..cc0420b34a52b3c979b27696d5af14c1d72a2270 100644 (file)
@@ -23,6 +23,7 @@ import {
   type OCPP20IdTokenType,
 } from '../../../../src/types/ocpp/2.0/Transaction.js'
 import { OCPPVersion } from '../../../../src/types/ocpp/OCPPVersion.js'
+import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.js'
 
 await describe('G03 - Remote Start Pre-Authorization', async () => {
   let service: OCPP20IncomingRequestService | undefined
@@ -60,7 +61,7 @@ await describe('G03 - Remote Start Pre-Authorization', async () => {
   })
 
   afterEach(() => {
-    // Reset service and mock charging station state
+    standardCleanup()
     mockChargingStation = undefined
     service = undefined
   })
index 49f0929c4a653bf97ed1d45b9cde21573c642a28..6fa4185a774a9d41bfed2f1b6f246e47a8365b60 100644 (file)
@@ -21,6 +21,7 @@ import {
   OCPP20IdTokenEnumType,
 } from '../../../../src/types/ocpp/2.0/Transaction.js'
 import { Constants } from '../../../../src/utils/index.js'
+import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.js'
 import { createChargingStation } from '../../../ChargingStationFactory.js'
 import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js'
 import { createMockAuthService } from '../auth/helpers/MockFactories.js'
@@ -59,6 +60,7 @@ await describe('F01 & F02 - Remote Start Transaction', async () => {
   })
 
   afterEach(() => {
+    standardCleanup()
     OCPPAuthServiceFactory.clearAllInstances()
   })
 
index 2762fb1a782540c723129b580058639947fde018..0a4704639363035a5668d5ccf1fca9ee6acb2ed5 100644 (file)
@@ -28,6 +28,7 @@ import {
   OCPP20ReasonEnumType,
 } from '../../../../src/types/ocpp/2.0/Transaction.js'
 import { Constants } from '../../../../src/utils/index.js'
+import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.js'
 import { createChargingStation } from '../../../ChargingStationFactory.js'
 import { TEST_CHARGING_STATION_BASE_NAME } from '../../ChargingStationTestConstants.js'
 import { createMockAuthService } from '../auth/helpers/MockFactories.js'
@@ -78,6 +79,7 @@ await describe('F03 - Remote Stop Transaction', async () => {
   })
 
   afterEach(() => {
+    standardCleanup()
     OCPPAuthServiceFactory.clearAllInstances()
   })
 
@@ -388,7 +390,7 @@ await describe('F03 - Remote Stop Transaction', async () => {
     expect(Object.values(RequestStartStopStatusEnumType)).toContain(response.status)
 
     // OCPP 2.0 RequestStopTransaction response should only contain status
-    expect(Object.keys(response as object)).toEqual(['status'])
+    expect(Object.keys(response as object)).toStrictEqual(['status'])
   })
 
   await it('should handle custom data in request payload', async () => {
index 9444c174ef599623e7c280b607c7bcd10f703fd5..d47ce5c417011f671adb207f7549a1ec70996390 100644 (file)
@@ -25,6 +25,7 @@ import {
   SetVariableStatusEnumType,
 } from '../../../../src/types/index.js'
 import { Constants } from '../../../../src/utils/index.js'
+import { standardCleanup } from '../../../../tests/helpers/TestLifecycleHelpers.js'
 import { createChargingStation } from '../../../ChargingStationFactory.js'
 import {
   TEST_CHARGING_STATION_BASE_NAME,
@@ -62,6 +63,7 @@ await describe('B05 - Set Variables', async () => {
 
   // Reset singleton state after each test to ensure test isolation
   afterEach(() => {
+    standardCleanup()
     OCPP20VariableManager.getInstance().resetRuntimeOverrides()
   })
 
index cc4a119af85bc7175cbcbe6d6ed52f044910ecbf..8d9c3b76bd8f85664b6b88990efff0bb478fd860 100644 (file)
@@ -126,8 +126,8 @@ await describe('G02 - Heartbeat', async () => {
     )
 
     // All payloads should be identical empty objects
-    expect(payload1).toEqual(payload2)
-    expect(payload2).toEqual(payload3)
+    expect(payload1).toStrictEqual(payload2)
+    expect(payload2).toStrictEqual(payload3)
     expect(JSON.stringify(payload1)).toBe('{}')
     expect(JSON.stringify(payload2)).toBe('{}')
     expect(JSON.stringify(payload3)).toBe('{}')
@@ -179,7 +179,7 @@ await describe('G02 - Heartbeat', async () => {
     // According to OCPP 2.0 specification, HeartBeat request should be an empty object
     // This validates compliance with the official OCPP 2.0 standard
     expect(payload).toBeDefined()
-    expect(payload).toEqual({})
+    expect(payload).toStrictEqual({})
     expect(has('constructor', payload)).toBe(false)
 
     // Ensure it's a plain object and not an instance of another type
index 82cbe448ffc75d6e378a27740e300a2d052c3e3c..9bcd69035eeac0c34b7bf266a1831ccc35fdd022 100644 (file)
@@ -123,7 +123,7 @@ await describe('B07/B08 - NotifyReport', async () => {
     expect(payload.requestId).toBe(456)
     expect(payload.seqNo).toBe(1)
     expect(payload.tbc).toBe(false)
-    expect(payload.reportData).toEqual(reportData)
+    expect(payload.reportData).toStrictEqual(reportData)
     expect(Array.isArray(payload.reportData)).toBe(true)
     expect(payload.reportData).toHaveLength(1)
   })
@@ -205,7 +205,7 @@ await describe('B07/B08 - NotifyReport', async () => {
     expect(payload.requestId).toBe(789)
     expect(payload.seqNo).toBe(2)
     expect(payload.tbc).toBe(true)
-    expect(payload.reportData).toEqual(reportData)
+    expect(payload.reportData).toStrictEqual(reportData)
     expect(Array.isArray(payload.reportData)).toBe(true)
     expect(payload.reportData).toHaveLength(3)
   })
@@ -251,7 +251,7 @@ await describe('B07/B08 - NotifyReport', async () => {
     expect(payload.requestId).toBe(999)
     expect(payload.seqNo).toBe(0)
     expect(payload.tbc).toBe(true)
-    expect(payload.reportData).toEqual(reportData)
+    expect(payload.reportData).toStrictEqual(reportData)
     expect(Array.isArray(payload.reportData)).toBe(true)
     expect(payload.reportData).toHaveLength(1)
   })
@@ -276,7 +276,7 @@ await describe('B07/B08 - NotifyReport', async () => {
     expect(payload.requestId).toBe(100)
     expect(payload.seqNo).toBe(0)
     expect(payload.tbc).toBe(false)
-    expect(payload.reportData).toEqual([])
+    expect(payload.reportData).toStrictEqual([])
     expect(Array.isArray(payload.reportData)).toBe(true)
     expect(payload.reportData).toHaveLength(0)
   })
@@ -529,6 +529,6 @@ await describe('B07/B08 - NotifyReport', async () => {
     const expectedKeys = ['generatedAt', 'reportData', 'requestId', 'seqNo', 'tbc']
     const actualKeys = Object.keys(payload as object).sort()
     expectedKeys.sort()
-    expect(actualKeys).toEqual(expectedKeys)
+    expect(actualKeys).toStrictEqual(expectedKeys)
   })
 })
index 3b03ac3f2183ad1c0853d37dc4411cb6df8b70ea..f6a2cf7ecf082bce0238fe6da24ca75cd78e1166 100644 (file)
@@ -64,7 +64,7 @@ await describe('InMemoryAuthCache - G03.FR.01 Conformance', async () => {
 
       expect(cachedResult).toBeDefined()
       expect(cachedResult?.status).toBe(AuthorizationStatus.ACCEPTED)
-      expect(cachedResult?.timestamp).toEqual(mockResult.timestamp)
+      expect(cachedResult?.timestamp).toStrictEqual(mockResult.timestamp)
     })
 
     await it('should track cache hits in statistics', async () => {
index f49e2869f7d42b626049ac7c79e8ca65fcb2497f..03c56b94f8d6014c01d4a9ed5b0d762c8d89719f 100644 (file)
@@ -11,10 +11,11 @@ import type { AuthConfiguration } from '../../../../../src/charging-station/ocpp
 import { AuthComponentFactory } from '../../../../../src/charging-station/ocpp/auth/factories/AuthComponentFactory.js'
 import { OCPPVersion } from '../../../../../src/types/ocpp/OCPPVersion.js'
 import { createChargingStation } from '../../../../ChargingStationFactory.js'
+import { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js'
 
 await describe('AuthComponentFactory', async () => {
   afterEach(() => {
-    // Cleanup handled by test isolation - each test creates its own instances
+    standardCleanup()
   })
 
   await describe('createAdapters', async () => {
index 1ffbd928f9856b324199f7fd804723caf0802faf..938a5a708308da73b9e0e01dc398240dbac29b54 100644 (file)
@@ -9,12 +9,14 @@ import type { ChargingStation } from '../../../../../src/charging-station/Chargi
 
 import { OCPPAuthServiceFactory } from '../../../../../src/charging-station/ocpp/auth/services/OCPPAuthServiceFactory.js'
 import { OCPPVersion } from '../../../../../src/types/ocpp/OCPPVersion.js'
+import { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js'
 import { createMockAuthServiceTestStation } from '../helpers/MockFactories.js'
 
 await describe('OCPPAuthServiceFactory', async () => {
   // Clear all cached instances after each test to ensure test isolation
   afterEach(() => {
     OCPPAuthServiceFactory.clearAllInstances()
+    standardCleanup()
   })
 
   await describe('getInstance', async () => {
index 25808b54ec6d77bed1c25c2144fd7398fe21b57e..9553481de545d6d39bac3b79647f670c50e57b63 100644 (file)
@@ -17,11 +17,12 @@ import {
   type UnifiedIdentifier,
 } from '../../../../../src/charging-station/ocpp/auth/types/AuthTypes.js'
 import { OCPPVersion } from '../../../../../src/types/ocpp/OCPPVersion.js'
+import { standardCleanup } from '../../../../helpers/TestLifecycleHelpers.js'
 import { createMockAuthServiceTestStation } from '../helpers/MockFactories.js'
 
 await describe('OCPPAuthServiceImpl', async () => {
   afterEach(() => {
-    // Cleanup handled by test isolation - each test creates its own mock station
+    standardCleanup()
   })
 
   await describe('constructor', async () => {
index 49706f98c3a4cd9171c92656a0f5e2b72db40b07..db13cf29c3be75294b56bec7cb80231bc6262818 100644 (file)
@@ -93,7 +93,7 @@ await describe('AuthHelpers', async () => {
 
       const request = AuthHelpers.createAuthRequest(identifier, context, undefined, metadata)
 
-      expect(request.metadata).toEqual({ source: 'test' })
+      expect(request.metadata).toStrictEqual({ source: 'test' })
     })
   })
 
@@ -120,7 +120,7 @@ await describe('AuthHelpers', async () => {
 
       expect(result.status).toBe(AuthorizationStatus.EXPIRED)
       expect(result.method).toBe(AuthenticationMethod.REMOTE_AUTHORIZATION)
-      expect(result.additionalInfo).toEqual({ reason: 'Token expired on 2024-01-01' })
+      expect(result.additionalInfo).toStrictEqual({ reason: 'Token expired on 2024-01-01' })
     })
   })
 
@@ -480,7 +480,7 @@ await describe('AuthHelpers', async () => {
       expect(merged?.status).toBe(AuthorizationStatus.BLOCKED)
       expect(merged?.method).toBe(AuthenticationMethod.LOCAL_LIST)
       expect(merged?.isOffline).toBe(true)
-      expect(merged?.additionalInfo).toEqual({
+      expect(merged?.additionalInfo).toStrictEqual({
         attemptedMethods: 'LocalList, RemoteAuthorization',
         totalAttempts: 2,
       })
@@ -504,7 +504,7 @@ await describe('AuthHelpers', async () => {
 
       const sanitized = AuthHelpers.sanitizeForLogging(result)
 
-      expect(sanitized).toEqual({
+      expect(sanitized).toStrictEqual({
         hasExpiryDate: true,
         hasGroupId: true,
         hasPersonalMessage: true,
@@ -525,7 +525,7 @@ await describe('AuthHelpers', async () => {
 
       const sanitized = AuthHelpers.sanitizeForLogging(result)
 
-      expect(sanitized).toEqual({
+      expect(sanitized).toStrictEqual({
         hasExpiryDate: false,
         hasGroupId: false,
         hasPersonalMessage: false,
index c3ab62c7260a80ee205ca70ab65c559bcd2149cc..092076890d12c67e4101bb867358c42f799d8bbb 100644 (file)
@@ -149,7 +149,7 @@ await describe('UIHttpServer test suite', async () => {
     expect(res.body).toBeDefined()
     const parsedBody = JSON.parse(res.body ?? '{}') as Record<string, unknown>
     expect(parsedBody.status).toBe('success')
-    expect(parsedBody.hashIdsSucceeded).toEqual(['station-1', 'station-2'])
+    expect(parsedBody.hashIdsSucceeded).toStrictEqual(['station-1', 'station-2'])
   })
 
   await it('should include error details in failure response', () => {
@@ -168,7 +168,7 @@ await describe('UIHttpServer test suite', async () => {
     const parsedBody = JSON.parse(res.body ?? '{}') as Record<string, unknown>
     expect(parsedBody.status).toBe('failure')
     expect(parsedBody.errorMessage).toBe('Test error')
-    expect(parsedBody.hashIdsFailed).toEqual(['station-1'])
+    expect(parsedBody.hashIdsFailed).toStrictEqual(['station-1'])
   })
 
   await it('should create server with valid HTTP configuration', () => {
index d1901ff999b0c6724ec2697077c3cabd185851eb..9f1c538c6b0a267dd06de8356023357d6921c9ab 100644 (file)
@@ -52,7 +52,7 @@ await describe('Utils test suite', async () => {
   await it('should generate valid UUIDs and validate them correctly', () => {
     const uuid = generateUUID()
     expect(uuid).toBeDefined()
-    expect(uuid.length).toEqual(36)
+    expect(uuid.length).toStrictEqual(36)
     expect(validateUUID(uuid)).toBe(true)
     expect(validateUUID('abcdef00-0000-4000-9000-000000000000')).toBe(true)
     expect(validateUUID('abcdef00-0000-4000-a000-000000000000')).toBe(true)
@@ -171,7 +171,7 @@ await describe('Utils test suite', async () => {
     expect(convertToInt(null)).toBe(0)
     expect(convertToInt(0)).toBe(0)
     const randomInteger = randomInt(Constants.MAX_RANDOM_INTEGER)
-    expect(convertToInt(randomInteger)).toEqual(randomInteger)
+    expect(convertToInt(randomInteger)).toStrictEqual(randomInteger)
     expect(convertToInt('-1')).toBe(-1)
     expect(convertToInt('1')).toBe(1)
     expect(convertToInt('1.1')).toBe(1)
@@ -192,7 +192,7 @@ await describe('Utils test suite', async () => {
     expect(convertToFloat(null)).toBe(0)
     expect(convertToFloat(0)).toBe(0)
     const randomFloat = getRandomFloat()
-    expect(convertToFloat(randomFloat)).toEqual(randomFloat)
+    expect(convertToFloat(randomFloat)).toStrictEqual(randomFloat)
     expect(convertToFloat('-1')).toBe(-1)
     expect(convertToFloat('1')).toBe(1)
     expect(convertToFloat('1.1')).toBe(1.1)
@@ -252,7 +252,7 @@ await describe('Utils test suite', async () => {
     expect(typeof randomFloat === 'number').toBe(true)
     expect(randomFloat).toBeGreaterThanOrEqual(0)
     expect(randomFloat).toBeLessThanOrEqual(Number.MAX_VALUE)
-    expect(randomFloat).not.toEqual(getRandomFloat())
+    expect(randomFloat).not.toStrictEqual(getRandomFloat())
     expect(() => getRandomFloat(0, 1)).toThrow(new RangeError('Invalid interval'))
     expect(() => getRandomFloat(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY)).toThrow(
       new RangeError('Invalid interval')
@@ -267,7 +267,7 @@ await describe('Utils test suite', async () => {
       extractTimeSeriesValues(
         new CircularBuffer<TimestampedData>(Array, Constants.DEFAULT_CIRCULAR_BUFFER_CAPACITY)
       )
-    ).toEqual([])
+    ).toStrictEqual([])
     const circularBuffer = new CircularBuffer<TimestampedData>(
       Array,
       Constants.DEFAULT_CIRCULAR_BUFFER_CAPACITY
@@ -275,7 +275,7 @@ await describe('Utils test suite', async () => {
     circularBuffer.push({ timestamp: Date.now(), value: 1.1 })
     circularBuffer.push({ timestamp: Date.now(), value: 2.2 })
     circularBuffer.push({ timestamp: Date.now(), value: 3.3 })
-    expect(extractTimeSeriesValues(circularBuffer)).toEqual([1.1, 2.2, 3.3])
+    expect(extractTimeSeriesValues(circularBuffer)).toStrictEqual([1.1, 2.2, 3.3])
   })
 
   await it('should correctly identify async functions from other types', () => {