Skip to content
Valerio Coltrè edited this page Apr 11, 2015 · 1 revision

The following technique is useful for both REPL testing and unit tests.

Declaring a simple Component like:

var inlineComponent = function (config) { console.log(config); };
inlineComponent['@require'] = ['config'];

Can be immediately executed in REPL or unit tests using the following commands:

var ioc = require('electrolyte');
ioc._registerModule('inline', inlineComponent); // this registers the Component, exactly as when using ioc.create()
ioc.create('inline'); // ERROR: requires 'config'!
ioc.literal('config', { mypassword: 'helloworld0' });
ioc.create('inline'); // => { mypassword: 'helloworld0' }

When porting an existing project to electrolyte, these manual injection tools could be useful to track down erroneous declarations.

Clone this wiki locally