Juru
Juru can be used to give visibility of side-effects (i.e. asynchronous data fetching, storing data) that happens during the application runtime; making the application easier to test, and better at handling failures.
For instance, if a module performs a HTTP remote identity provider or fetches information from your local DB, you can test that module in isolation.
Table of Contents
How does it work?
It works by leveraging the iterable protocol to expose side-effects descriptors of your application.
Install
$ npm install --save juru
Usage
// main moduleconst co = const all call = const enhancedUser = { const remoteUser userPurchases = return }exports = moduleexports = exportsgenerator = enhancedUser const externalService = findUser: async id: 'remote-service-id' name: 'Jhon Doe' exportsexternalService = externalService const insternalStorage = findUserByExternalId: async id: 'local-id' externalId: 'remote-service-id' purchases: exportsinsternalStorage = insternalStorage const userPresenter = ...user purchases: userPurchasespurchases exportsuserPresenter = userPresenter
// test fileconst test = const all call = const externalService generator insternalStorage =
Alternatives
- Proxyquire
- Rewire
- Sinon