-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use book in unit testing using mocha #1
Comments
Okay so I got sails to lift correctly and any ES6 syntax within the project works perfectly using the line |
Glad you could fix the first error - do you have a test repo so I can look at how your tests are set up etc? |
Same problem here, any thought how to enable babel in test environment? I think it's because our test case are loaded before sails has not been loaded. Even if sails already has babel, it will affect everything inside the sails object, not test case that outside sails object. |
Alright, what I expected is true: use this as bootstrap when doing testing. Change it to something that meet our needs (I don't pretty understand about babel config actually). bootstrap.test.js
and don't forget to run it, example in package.json, I put all my unit test at
|
You need the proper polyfills. Here are instructions for Babel 6, which is not supported by sails-hook-babel currently: See issue #10 |
I try to run some tests with mocha, and only problem on my way was babel's presets and plugins: Babel could not get configs from
config/babel.js: module.exports.babel = {
polyfill: true,
ignore: /\/node_modules\/(?!lib\/)/,
"presets": [
"es2015",
"stage-0",
"react"
],
"plugins": [
"transform-decorators-legacy",
"add-module-exports"
]
}; mocha.opts:
bootstrap.test.js: import Sails from 'sails';
import RC from 'rc';
before((done) => {
Sails.lift(RC('sails'), (err, server) => {
if (err) {
return done(err);
}
// here you can load fixtures, etc.
done(err, Sails);
});
});
after((done) => {
// here you can clear fixtures, etc.
Sails.lower(done);
});
it('should lift sails', (done) => {
done();
}); |
Hello, Great work! The hook works perfectly when I do a sails lift on the console, but while running unit tests through mocha, it fails with a syntax error,
"before all" hook:
this is the way I lift sails in mocha
Any ideas what is preventing it from working correctly? Thanks
The text was updated successfully, but these errors were encountered: