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.
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)