title: Jest mock class method on a test-by-test basis
body: <p>I'm trying to mock out a utility library class with a method that returns a JSON. </p>
  
  <p>Actual library structure</p>
  
  <pre><code>module.exports = class Common() {
    getConfig() {
    return {
      real: 'data'
    }
  }
  </code></pre>
  
  <p>The file under test looks like:</p>
  
  <pre><code>
  const Common = require('./common');
  const common = new Common();
  const config = common.getConfig();
  
  ...
  
  const someFunction = function() {
    // config.real is used inside this function
  }
  </code></pre>
  
  <p>I'm trying to mock out the Common class and return a different config JSON for each Jest test. </p>
  
  <pre><code>const fileUnderTest = require('./../fileUnderTest.js');
  const Common = require('./../common.js');
  jest.mock('./../common.js');
  
  describe('something', () =&gt; {
    it('test one', () =&gt; {
      Common.getConfig = jest.fn().mockImplementation(() =&gt; {
        return {
          real : 'fake' // This should be returned for test one
        };
      });
  
      fileUnderTest.someFunction(); //config.real is undefined at this point
    });
  
    it('test two', () =&gt; {
    Common.getConfig = jest.fn().mockImplementation(() =&gt; {
        return {
          real : 'fake2' // This should be returned for test two
        };
      });
    })
  })
  </code></pre>
  
  <p>Is it possible to set the return value from the mock class method created by the automock of <code>common.js</code> at the top of the test file? </p>
  
  <p>I've tried to use <code>mockReturnValueOnce()</code> etc. </p>