From 66351458ed4df9437189439031521e7314887b6f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Mon, 16 Mar 2026 22:56:52 +0100 Subject: [PATCH] fix(tests): add second flushMicrotasks for RequestStopTransaction listener 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. --- ...CPP20IncomingRequestService-RequestStopTransaction.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts index edee1bc9..956979ed 100644 --- a/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts +++ b/tests/charging-station/ocpp/2.0/OCPP20IncomingRequestService-RequestStopTransaction.test.ts @@ -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) -- 2.53.0