Rewire: How is it possible for this function to execute without returning the specified return value
<p>I am using the <a href="https://www.npmjs.com/package/rewire" rel="nofollow noreferrer">Rewire package</a> to inject mocks in connection with doing unit testing. I was hoping to be able to test private functions in my modules:</p>

<pre><code>var a = 10;
var b = 20;

function adder (){ //not exported
    console.log(a);
    console.log(b);
    return a + b;
};
</code></pre>

<p>by doing this:</p>

<pre><code>var rewire = require('rewire'),
    md = rewire('./module'),
    mock = {a: 30, b: 40},
    cb = md.__get__('adder');

console.log(md.__with__(mock)(cb));
</code></pre>

<p>which logs the following to the console:</p>

<pre><code>30
40
undefined
</code></pre>

<p>I find this strange because the logging of the <code>30</code> and <code>40</code> seems to indicate that <code>adder()</code> has successfully been invoked with the <code>mock</code>.</p>

<p>But why is the return value <code>undefined</code> in stead of <code>70</code>?</p>