Hey Marek, we have had a lot of similar questions over the past few years. Here is what we came up with:
First, we built tooling to architect scalable Forge apps with Typescript, which allows us to destructure apps into many small testable parts, and reuse shared parts in different places of the app (frontend/backend).
With that in place, we write our backend with Effect, which itself has a lot of the concepts you described in your example baked in. Effect comes with HTTP, Cache, and many other abstractions that help to write testable code where you can easily plug in in-memory or mock implementations. For example, our Effect Jira HTTP client has a pluggable fetch interface. For production, we bind the fetch interface with an adapter that adapts the @forge/bridge invoke interface to a standard fetch interface. For testing, we can easily replace the invoke call with mock. For the most part, this has worked great (exceptions are strange @forge/bridge invokeRemote which has GraphQL-like semantics).
Obviously, Effect is an opinionated choice, but you could just as well use https://inversify.io/ or other DI libraries to help you with IoC if you prefer to stick to more traditional TS.
Unfortunately, Forge does not provide any emulators or mock implementations for KVS/SQL etc. As it is today, you have to either mock or do E2E tests.
Maybe this helps.