jeudi 21 mars 2019

How to test nodejs modules that transitively require itself

Assume the following scenario :

Rest client is a module, which has many middlewares; which are themselves modules.

Now, we're trying to create a new middleware that requires client itself to fetch/update metadata for the client input url.

Testing this middleware, will bring in a published version of the client from npm registry, but we want to serve our local client middleware. (because middleware has a devDependency on the client)

Problem is that getting the published version will not allow testing the request pipeline with this middleware. And we want to initiate the client with this middleware, when we're testing the middleware itself to send a request to fetch data.

The middleware is smart enough to not request metadata for metadata, so it will skip it.

Aucun commentaire:

Enregistrer un commentaire