title: How do I properly test a function that use axios.get and cheerios.load functions with mocha and chai?
body: <p>I have this index.js file</p>
  
  <pre><code>    const axios = require("axios");
      const cheerio = require('cheerio');
  
      const fetchData = async (webpage) =&gt; {
          const result = await axios.get(webpage);
          return cheerio.load(result.data);
      }
      const extractData = async (webPage) =&gt; {
          const $ = await fetchData(webPage);
          const numMains = $('.rank').text();
          //Should return the following string 
          //1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.
          return numMains;
      }
  
      const siteUrl = "https://news.ycombinator.com/";
  
      (async (webPage) =&gt; {console.log(await extractData(webPage));})(siteUrl);
  
      module.exports = {
          extractData: extractData
      }
  </code></pre>
  
  <p>And I have this test.js file</p>
  
  <pre><code>    var chai = require('chai');
      var expect = chai.expect;
      var functionNames = require('../index.js');
  
      describe('extractData() Unit-Test', () =&gt; {
        it('This function should return a given string', () =&gt; {
  
          // 1. ARRANGE
          const siteUrl = "https://news.ycombinator.com/";
          const shouldResult = "1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.";
  
          // 2. ACT
          const result = functionNames.extractData(siteUrl);
  
          // 3. ASSERT
          expect(result).to.be.equal(shouldResult);
  
        });
      });
  </code></pre>
  
  <p>*I'm not getting pass with this AssertionError: *</p>
  
  <pre><code>    AssertionError: expected {} to equal '1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.'
  </code></pre>
  
  <p><strong>Does someone know what I'm doing wrong and how can I solve this problem?</strong></p>