Unit testing our engine

Next, let's test our create engine function. Like our previous createUser request handler, the src/engines/users/create/index.js module contains two import statements, which makes it difficult to test. Therefore, just like before, we must pull these dependencies out, and import them back into src/index.js:

import createUserValidator from './validators/users/create';...const handlerToValidatorMap = new Map([  [createUserHandler, createUserValidator],]);...app.post('/users', injectHandlerDependencies(createUserHandler, client, handlerToEngineMap, handlerToValidatorMap, ValidationError));

Then, update the injectHandlerDependencies function to inject the validator function into the handler:

function injectHandlerDependencies( ...

Get Building Enterprise JavaScript Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.