title: how to unmock a single instance method with jest
body: <p>coming from rspec, i am having trouble understanding mocking with jest. the approach i am trying for, is to automock a class's constructor and all of it's functions, and then unmock them one by one to test only that one function. the only documentation i can find on it, is with using 2 classes, mocking 1 class, and then testing that those functions are called from the other unmocked class.</p>
  
  <p>below is a basic, contrived idea of what i am trying to do. can someone direct me to the jest-way of doing this?</p>
  
  <p>foo.js</p>
  
  <pre><code>class Foo
    constructor: -&gt;
      this.bar()
      this.baz()
    bar: -&gt;
      return 'bar'
    baz: -&gt;
      return 'baz'
  </code></pre>
  
  <p>foo_test.js</p>
  
  <pre><code>// require the class
  Foo = require('foo')
  
  // mock entire Foo class methods
  jest.mock('foo')
  
  // unmock just the bar method
  jest.unmock(Foo::bar)
  
  // or by
  Foo::bar.mockRestore()
  
  // and should now be able to call
  foo = new Foo
  foo.bar() // 'bar'
  foo.baz() // undefined (still mocked)
  
  // i even tried unmocking the instance
  foo = new Foo
  jest.unmock(foo.bar)
  foo.bar.mockRestore()
  </code></pre>