]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix(tests): add second flushMicrotasks for RequestStopTransaction listener
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 16 Mar 2026 21:56:52 +0000 (22:56 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 16 Mar 2026 21:56:52 +0000 (22:56 +0100)
The async chain in requestStopTransaction traverses a dynamic import()
in checkConnectorStatusTransition (OCPPServiceUtils), which may resolve
after the first setImmediate on macOS + Node 22. A second flush ensures
the StatusNotification call completes before the assertion.

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

index edee1bc9237b5a9146b3052a4c624a54b44e2fab..956979ed16540cf349b53076a939e653205eed60 100644 (file)
@@ -262,6 +262,10 @@ await describe('F03 - Remote Stop Transaction', async () => {
         response
       )
 
+      // Two flushes needed: the async chain in requestStopTransaction traverses a
+      // dynamic import() in checkConnectorStatusTransition, which may resolve after
+      // the first setImmediate on some platforms (observed on macOS + Node 22).
+      await flushMicrotasks()
       await flushMicrotasks()
 
       assert.strictEqual(requestHandlerMock.mock.callCount(), 2)