1
我在帆和摩卡上運行sailsjs,mocha和babel。當我跑,我之前函數運行測試之前啓動帆的應用程序,我得到這個:Babel不適用於Mocha並啓動節點服務器
> 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
對於我的生活,我無法弄清楚如何使摩卡運行巴貝爾和運行巴貝爾帆同時工作。
我之前()的代碼如下所示:
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();
});
});