title: Jest Enzyme unit test axios api services with coverage
body: <p>I'm new to jest, enzyme unit tests. I have the following code and it is working as expected</p>
  <blockquote>
  <p>Component</p>
  </blockquote>
  <pre><code>import productService from './../../../productService';
  
  constructor(props) {
      super(props);
      this.productService = new productService();
  }
  
  componentDidMount() {
      this.productService.getProductList().then(res =&gt; {
          if (res.status === &quot;Success&quot;) {
              /// Some actions 
          } else {
              /// Some actions 
          }
      });
  }
  </code></pre>
  <blockquote>
  <p>productService.js</p>
  </blockquote>
  <pre><code>import axios from 'axios';
  
  class productService {
  
      constructor() {
          this.state = {
              apiUrl: process.env.REACT_APP_API_URL
          }
      }
  
      getProductList() {
          return axios.get(this.state.apiUrl + &quot;products/listProducts&quot;)
              .then(res =&gt; {
                  return res.data;
              }).catch(err =&gt; {
                  return err;
              });
      }
  
  }
  export default productService;
  </code></pre>
  <p>and I have tried <code>axios-mock-adapter</code> for mocking the API and its response.</p>
  <pre><code>import axios from 'axios';
  import MockAdapter from 'axios-mock-adapter';
  describe('User List Component Unit Tests', () =&gt; {
      var mock = new MockAdapter(axios);
  
      mock.onGet(&quot;/products/listProducts&quot;).reply(200, {
          &quot;status&quot;: &quot;Success&quot;,
          &quot;data&quot;: [...]
      });
  
      it('Should trigger the product list api', () =&gt; {
          wrapper.find('myComponent').instance().componentDidMount();
  
          axios.get(&quot;/products/listProducts&quot;).then(function (response) {
              console.log(response);
          });
      });
  });
  </code></pre>
  <p>So the test will run successfully but I can't see the coverage in the coverage report.</p>
  <p><a href="https://i.stack.imgur.com/Irz16.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Irz16.png" alt="enter image description here" /></a></p>
  <p>Any help would be appreciated.</p>