How to test MsgEffect? #353
-
Hello! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @sukazavr!
import { contextFactory, lookup, createEffectContext } from '@marblejs/core';
const context = await contextFactory([
// ... registered dependencies
]);
const ask = lookup(context);
// ...
const effectContextMock = createEffectContext({ ask, client: {} as any });
// ...
someEffect$(event$, effectContextMock).subscribe(
// ...
); Basically thats all building blocks that are needed. In practice the incoming |
Beta Was this translation helpful? Give feedback.
Hi @sukazavr!
MessagingTestBed
was on its way but I postponed the implementation due to the ongoing process of introducing version 4.0.So far the scope for the next major release doesn't include it but since it is a non breaking feature it can be added in the next 4.1 version. But directly answering your question...
MsgEffect
is just a function. It takesA
and returnsB
. You can write a simple utility function that packs an incomingEvent
into the stream and then feeds it in. Additionaly theEffectContext
can be easily mocked. The only thing that is worth providing is theContext
object that you can build usingcontextFactory
function from@marblejs/core
and passing it throughlookup
fun…