If I were designing import in JS I&#x27;d give option to inject dependency into imported module that overrides the one that language would normally load from file.<p>Like this:<p><pre><code>    &#x2F;&#x2F; model.js:
    var db = require(&quot;db&quot;);


    &#x2F;&#x2F; controller.js:
    var model = require(&quot;model&quot;);


    &#x2F;&#x2F; test.js:
    var model = require(&quot;model&quot;, { db: require(&quot;db_mock&quot;) });

</code></pre>
I could probably implement something like that as webpack plugin.