title: How to mock chrome APIs using JEST framework?
body: <p>I want to mock the chrome apis using jest framework. 
  For example I am using <code>chrome.browserAction.setIcon</code> to send a message to background script. How can I mock <code>chrome.browserAction.setIcon</code> or any other apis such as <code>chrome.runtime.sendMessage</code> to test if the method has been called?</p>
  
  <p>I have tried using jest.spyOn() for testing whether the method has been called. </p>
  
  <p>Here is the test method</p>
  
  <pre><code> test("mock testing chrome",()=&gt;{
       spyOn(chrome,
            chrome.browserAction.setIcon);
       content.chromemocktest();
       expect(spy).toHaveBeenCalledWith({path:"/images.png"});
   });
  </code></pre>
  
  <p>And the method I am testing is :</p>
  
  <pre><code> chromemocktest: function(){
       chrome.browserAction.setIcon({path:"/image.png"});
  
   }    
  </code></pre>
  
  <p>When I run the <code>npm run test</code> for running test cases, it is throwing an error as shown below.</p>
  
  <pre><code> &lt;spyOn&gt; : stub() method does not exist
   Usage: spyOn(&lt;object&gt;, &lt;methodName&gt;)
  </code></pre>