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!
MessagingTestBedwas 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...
MsgEffectis just a function. It takesAand returnsB. You can write a simple utility function that packs an incomingEventinto the stream and then feeds it in. Additionaly theEffectContextcan be easily mocked. The only thing that is worth providing is theContextobject that you can build usingcontextFactoryfunction from@marblejs/coreand passing it throughlookupfun…