title: How to properly stub a function return value?
body: <ul>
  <li><strong>Premise:</strong> JS ES6, NodeJS</li>
  <li><strong>Testing Framework:</strong> <a href="http://www.node-tap.org/" rel="nofollow noreferrer">TAP</a></li>
  <li><strong>Mocking Library:</strong> <a href="https://github.com/testdouble/testdouble.js" rel="nofollow noreferrer">testdouble.js</a></li>
  </ul>
  
  <hr>
  
  <p>I am attempting to mock the return value for the method of my class and keep receiving this error:</p>
  
  <blockquote>
    <p>not ok Unsatisfied verification on test double.    Wanted:     - called with <code>(true)</code>.    But there were no invocations of the test double.</p>
  </blockquote>
  
  <p>Here is my testing code:</p>
  
  <pre><code>// Imports for unit testing
  const tap = require('tap');
  const Subject = require('../src/iTunesClient.js');
  const td = require('testdouble');
  
  let reqJson;
  
  // Ensure the iTunes class methods are called
  tap.test('iTunesClient class methods function as intended', (t) =&gt; {
    t.beforeEach((ready) =&gt; {
      reqJson = td.replace('../src/reqJson.js');
      ready();
    });
  
    t.afterEach((ready) =&gt; {
      td.reset();
      ready();
    });
  
    t.test('iTunesClient.getData', (assert) =&gt; {
      const callback = td.function();
      const subject = new Subject();
      subject.setTerm('abc 123');
      subject.setURL();
  
      td.when(reqJson.get(td.callback)).thenCallback(true);
  
      subject.getData(callback);
  
      td.verify(callback(true));
      assert.end();
    });
  
    t.end();
  });
  </code></pre>
  
  <p>Specifically, this line is related to my issue:</p>
  
  <pre><code>td.verify(callback(true));
  </code></pre>
  
  <p>How can I fake the callback value of <code>true</code> for <code>reqJson.get()</code>? Right now, <code>Subject.geData()</code> is a method of the <code>iTunesClient</code> class which calls another file, <code>reqJson.js</code>, to use its exported <code>get()</code> method.</p>