Mocker Middleware
The Mocker Middleware in Missive.js provides developers with the ability to bypass the handler and return a predefined value. This is useful for testing purposes or to simulate a specific behavior.
It’s also very efficient to use in development when you want to test a specific behavior without having to implement the whole logic.
How to use it
Section titled “How to use it”As for any Middleware, you can use it by adding it to the bus instance.
const queryBus = createQueryBus<QueryHandlerRegistry>();queryBus.useMockerMiddleware({ intents: { createUser: async (envelope) => ({ success: true, userId: '1234', }), },});Explanation
Section titled “Explanation”With the Mocker Middleware you can mock results for specific intents. There is not much to say about this middleware, it’s pretty straightforward. You provide a function that will be called instead of the handler.
Added Stamps
Section titled “Added Stamps”The Feature Flag Middleware is going to add:
-
type HandledStamp<R> = Stamp<R, 'missive:handled'>;
This stamp will always be there, added by this middleware or the final handler.
Going further
Section titled “Going further”
Missive.js. MIT License.
Powered by Astro Starlight.
Inspired by Symfony Messenger