【发布时间】:2015-07-12 07:32:17
【问题描述】:
我在sails 和mocha 上运行sailsjs、mocha 和babel。当我运行时,我的 before 函数在运行测试之前启动sails 应用程序,我得到这个:
> 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
对于我的生活,我无法弄清楚如何让 mocha running babel 和sails running babel 同时工作。
我的 before() 代码如下所示:
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();
});
});
【问题讨论】:
标签: node.js unit-testing sails.js mocha.js