title: Replacement for `require.context` when running Jest
body: <p>I'm trying to run tests for my React application using <code>Jest</code>, but my tests keep on failing due to an error saying that <code>require.context</code> is not a function. I am looking for a replacement for that functionality that <code>Jest</code> will not choke on. I am trying to dynamically <code>require</code> and modify some <code>*.vue</code> file from <code>Vue.js</code>to be used later on in my application. In addition to this, I occasionally get errors that don't recognize the format of the <code>.vue</code> files and say that they can't be parsed. This is the code in question:</p>
  
  <pre><code>function inject(comp) {
      comp.methods = Object.assign({}, comp.methods, stub.methods);
      return comp;
  } 
  
  let req = require.context('./', false, /\.vue$/);
  components.forEach(function (component) {
      try {
          let filePath = __dirname + "\\" + component + '.vue';
          let injected = inject(req(filePath));
          Vue.component(getComponentName(component), injected);
  
          let appComponent = {
              name: injected.name,
              props: {
                  autocompletion: {
                      metadata: getComponentName('template'),
                      score: xTemplatesScore,
                      attributes: injected.props || []
                  }
              }
          };
  
          appComponents.push(appComponent);
      } catch (err) {
          console.log(err);
          console.error('Vue file was not found for component:' + component + '. Please rename your files accordingly ( component-name.vue )');
      }
  });
  </code></pre>