dimanche 12 juillet 2015

Babel not working with Mocha and starting Node server

I am running sailsjs, mocha, and babel on sails and mocha. When I run, my before function to start the sails app before running tests, I get this:

> PORT=9999 NODE_ENV=test mocha --recursive --compilers js:babel/register



lifting sails
  1) "before all" hook

  0 passing (757ms)
  1 failing

  1)  "before all" hook:
     Uncaught Error: only one instance of babel/polyfill is allowed

For the life of me, I can't figure out how to make mocha running babel and sails running babel at the same time work.

My before() code looks like this:

import Sails from 'sails'

// Global before hook
before(function (done) {

  console.log('lifting sails')

  // Lift Sails with test database
  Sails.lift({
    log: {
      level: 'error'
    },
    models: {
      connection: 'testMongoServer',
      migrate: 'drop'
    },
    hooks: {
      // sails-hook-babel: false
      babel: false
    }
  }, function(err) {
    if (err) {
      return done(err);
    }

    // Anything else you need to set up
    // ...
    console.log('successfully lifted sails')

    done();
  });
});

Aucun commentaire:

Enregistrer un commentaire