title: Mock named exports for testing using Jest
body: <p>I have a <code>Helper.js</code> file with several helper functions as below that is being used in different components.</p>
  
  <pre class="lang-js prettyprint-override"><code>    export function buildOptions(elem) { 
          var oList=[];   
          for (var i=0; i &lt; field.length; i++) {
              oList.push (
                &lt;option value={options[i]["id"]}&gt;
                    {options[i][elem]}
                &lt;/option&gt;
              )
           }    
           return oList;
        }
  
        export function B(){
             .....
        }
  </code></pre>
  
  <p>Here is a component which makes use of the function defined in <code>Helper.js</code> file. I am writing tests for the component and I would like to mock the external function being called here.</p>
  
  <pre class="lang-js prettyprint-override"><code>    import React from 'react';
      import ReactDOM from 'react-dom';
      import { buildOptions, A} from './Helper.js';
  
      class DemoComponent extends React.Component {
          constructor(props) {
              super(props);
          }
  
          add(e, index) {
              ....
          }
  
  
          render() {
              var o_list=buildOptions("name");
  
              return (
                 &lt;div&gt;
                    ...
                    &lt;select required className={selectClass}  &gt;
                        {o_list}
                    &lt;/select&gt;  
                    ...           
                    &lt;button type="button" onClick={(e) =&gt; this.add(e, this.props.index)}&gt;
                          Add 
                    &lt;/button&gt;
                 &lt;/div&gt;
              );
           };
       }
  </code></pre>
  
  <p>I am new to Jest/Enzyme and I am unable to figure out how to mock the external function buildOptions. I am unable to figure out how to mock the external buildOptions function.Could anyone please help me with this.
  Here is my test code:</p>
  
  <pre class="lang-js prettyprint-override"><code>import React from 'react';
  import { mount, shallow } from 'enzyme';
  import { buildOptions } from '../components/Helper.js';
  import DemoComponent from '../components/DemoComponent';
  
  describe('Democomponent', () =&gt; {
  
    it('should render required elements', () =&gt; {
  
      const wrapper = shallow(
         &lt;DemoComponent 
          index={0}/&gt; 
      );
      //
      tests
  }); 
  </code></pre>