title: Turning an ES5 React + Flux dispatcher test into ES6 fails
body: <p><strong>Their __tests__/TodoStore-test.js file:</strong>
  <a href="https://github.com/facebook/flux/blob/master/examples/flux-todomvc/js/stores/__tests__/TodoStore-test.js" rel="nofollow">https://github.com/facebook/flux/blob/master/examples/flux-todomvc/js/stores/<strong>tests</strong>/TodoStore-test.js</a></p>
  
  <p><strong>And their js/dispatcher/AppDispatcher.js file:</strong>
  <a href="https://github.com/facebook/flux/blob/master/examples/flux-todomvc/js/dispatcher/AppDispatcher.js" rel="nofollow">https://github.com/facebook/flux/blob/master/examples/flux-todomvc/js/dispatcher/AppDispatcher.js</a></p>
  
  <p>In their case, the dispatcher is simply this:</p>
  
  <pre><code>var Dispatcher = require('flux').Dispatcher;
  module.exports = new Dispatcher();
  </code></pre>
  
  <p>And in their test's <code>beforeEach</code> it resets:</p>
  
  <pre><code>AppDispatcher = require('../../dispatcher/AppDispatcher');
  </code></pre>
  
  <p>Now, in my own project I'd like to use ES6's way of doing things. I'm not sure how, though. The differences between <code>require</code> and <code>import</code> elude me.</p>
  
  <p><strong>My dispatcher:</strong></p>
  
  <pre><code>import { Dispatcher } from 'flux';
  var dispatcher = new Dispatcher({
      logLevel: 'ALL'
  });
  export default dispatcher;
  </code></pre>
  
  <p>Which–as a piece in the app–works fine in my app, but the <code>require</code> example above isn't having it.</p>
  
  <p><strong>The part of the test that needs to be converted to ES6's <code>import</code>:</strong></p>
  
  <pre><code>beforeEach(function() {
      AppDispatcher = require('./../src/dispatcher/dispatcher');
      TodoStore = require('./../src/stores/TodoStore');
      callback = AppDispatcher.register.mock.calls[0][0];
  });
  </code></pre>
  
  <p>But, of course, this does not work:</p>
  
  <pre><code>beforeEach(function() {
      AppDispatcher = import './../src/dispatcher/dispatcher';
      // snip
  });
  </code></pre>
  
  <p>Or:</p>
  
  <pre><code>import dispatcher from './../src/dispatcher/dispatcher';
  beforeEach(function() {
      AppDispatcher = new dispatcher();
      // snip
  });
  </code></pre>
  
  <p>I'm just doing by trial and error now and it's taking way too much time just to write a <em>test</em>.</p>
  
  <p>My thought process:</p>
  
  <p>They require whatever their dispatcher file outputs, which is always a <code>new Dispatcher()</code>.</p>
  
  <p>In my case, I'm creating a <code>new Dispatcher</code> and <code>export</code> that instance. Instead, I'd probably need to not instantiate it in the dispatcher file, but leave that up to the <code>export</code>, e.g.: <code>export default new Dispatcher()</code>, but that looks awful.</p>
  
  <p>But no matter what I try I keep getting errors like:</p>
  
  <p><code>TypeError: Cannot read property 'register' of undefined</code></p>
  
  <p>Does anybody have a clue how to get this one up and running?
  Much obliged!</p>