title: Is it possible to use ES6 modules in Mocha tests?
body: <p>ES6, Windows 10 x64, Node.js 8.6.0, Mocha 3.5.3</p>
  
  <p>Is it possible to use ES6 modules in Mocha tests? I have the problems with <code>export</code> and <code>import</code> keywords.</p>
  
  <pre><code>/* eventEmitter.js
   */
  
  /* Event emitter. */
  export default class EventEmitter{
  
      constructor(){
  
          const subscriptions = new Map();
  
          Object.defineProperty(this, 'subscriptions', {
              enumerable: false,
              configurable: false,
              get: function(){
                  return subscriptions;
              }
          });
      }
  
      /* Add the event listener.
       * @eventName - the event name. 
       * @listener - the listener.
       */
      addListener(eventName, listener){
          if(!eventName || !listener) return false;
          else{
              if(this.subscriptions.has(eventName)){
                  const arr = this.subscriptions.get(eventName);
                  arr.push(listener);
              }
              else{
                  const arr = [listener];
                  this.subscriptions.set(eventName, arr);
              }
              return true;
          }
      }
  
      /* Delete the event listener.
       * @eventName - the event name. 
       * @listener - the listener.
       */
      deleteListener(eventName, listener){
          if(!eventName || !listener) return false;
          else{
              if(this.subscriptions.has(eventName)){
                  const arr = this.subscriptions.get(eventName);
                  let index = arr.indexOf(listener);
  
                  if(index &gt;= 0){
                      arr.splice(index, 1);
                      return true;
                  }
                  else{
                      return false;
                  }
              }
              else{
                  return false;
              }
          }
      }
  
      /* Emit the event.
       * @eventName - the event name. 
       * @info - the event argument.
       */
      emit(eventName, info){
          if(!eventName || !this.subscriptions.has(eventName)) {
              return false;
          }
          else{
              for(let fn of this.subscriptions.get(eventName)){
                  if(fn) fn(info);
              }
              return true;
          }
      }
  }
  </code></pre>
  
  <p>Mocha test:</p>
  
  <pre><code>/* test.js 
   * Mocha tests.
   */
  import EventEmitter from '../../src/js/eventEmitter.js';
  
  const assert = require('assert');
  
  describe('EventEmitter', function() {
    describe('#constructor()', function() {
      it('should work.', function() {
          const em = new EventEmitter();
          assert.equal(true, Boolean(em));
      });
    });
  });
  </code></pre>
  
  <p>I launch the <code>mocha</code> directly through the PowerShell console. The result:</p>
  
  <p><a href="https://i.stack.imgur.com/4ft8c.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4ft8c.png" alt="enter image description here"></a></p>