-
Notifications
You must be signed in to change notification settings - Fork 45
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
Support ES7 via babel #61
Comments
You are correct, wallaby supports ES6 and doesn't yet support ES7. It has to instrument code (parse, change and emit) before preprocessors, so has to be able to understand ES7 on all those stages. While it is technically possible to extend wallaby core to support ES7, before it becomes stable mainstream I'd rather let external tools, such as babel, to provide the support for it in wallaby. So the good news is that at the moment I'm working on 'compilers' support in wallaby. The concept of compilers is similar to preprocessors, but they will run before wallaby instrumentation. CoffeeScript and TypeScript will be supported via compilers, I will include ES7 via babel compiler as well. This way wallaby core will not have to 'understand' TypeScript/CoffeeScript/ES7 natively, but rather work with (instrument) generated ES5/ES6. Compilers support is almost ready and will be released some time next week. |
+1 e.g. it('should get response', async ()=>{
var resp = await api('users.get', {});
resp.should.not.be.equal(undefined);
}) much simplier than it('should get response', (done)=>{
api('users.get', {})
.then((resp)=>{
resp.should.not.be.equal(undefined);
done();
});
}) |
I'm getting something like this:
|
@okonet I'm trying to reproduce the issue, is js/modules/Flux.js this file /~https://github.com/facebook/flux/blob/master/dist/Flux.js? Probably something else as I can't reproduce it on this file. Could you please share the file where the issue is reproduced? |
Og sorry it was a bit misleading... Actually it has nothing to do with this particular file. I've seen the same error for other files in the project but when I've tried to localize the issue and ignored them... I'm still not sure what's the problem but it might be webpack post processor (which I use) or something else. Any way you could gide me? Here is the config: var wallabyWebpack = require('wallaby-webpack');
var babel = require('babel');
var webpack = require('webpack');
var wallabyPostprocessor = wallabyWebpack({
plugins: [
new webpack.DefinePlugin({
_PRODUCTION_: true,
})
]
}
);
module.exports = function (wallaby) {
return {
// set `load: false` to all of source files and tests processed by webpack
// (except external files),
// as they should not be loaded in browser,
// their wrapped versions will be loaded instead
files: [
{ pattern: 'node_modules/chai/chai.js', instrument: false},
{ pattern: 'js/**/*.js*', load: false },
{ pattern: 'js/**/__tests__/*_spec.*', ignore: true }
],
tests: [
{ pattern: 'js/**/__tests__/*_spec.*', load: false }
],
compilers: {
'js/**/*.js*': wallaby.compilers.babel({
babel: babel,
// other babel options
stage: 0 // https://babeljs.io/docs/usage/experimental/
}),
'js/**/*.coffee': wallaby.compilers.coffeeScript({
// CoffeeScript compiler specific options
})
},
testFramework: "mocha@2.0.1",
postprocessor: wallabyPostprocessor,
debug: true,
bootstrap: function () {
var mocha = wallaby.testFramework;
mocha.ui('bdd');
var expect = chai.expect;
var should = chai.should();
// required to trigger tests loading
window.__moduleBundler.loadTests();
}
};
}; I'm using babel@5.1.4 |
And here is the source of Flux.js import Flummox from 'flummox';
import NavigationActions from './Navigation/actions/NavigationActions.js';
import NavigationStore from './Navigation/stores/NavigationStore.js';
import EntitiesActions from './EntitySelector/actions/EntitiesActions.js';
import EntitiesStore from './EntitySelector/stores/EntitiesStore.js';
export default class Flux extends Flummox {
constructor() {
super();
this.createActions('navigation', NavigationActions);
this.createStore('navigation', NavigationStore, this);
this.createActions('entities', EntitiesActions);
this.createStore('entities', EntitiesStore, this);
}
} |
Your configuration looks good. I have created the repo /~https://github.com/wallabyjs/wallaby-webpack-es7 with your file structure and your config file. On a couple of simple files it works fine. Could you please have a look and perhaps try to add something that I'm missing to break it? |
Ok I've isolated the case. It's related to React and PhantomJS (Function.bind). BTW I wasn't aware wallaby uses phantomjs... Related: duojs/test#55 I'll commit failing test and fix to the repository. |
Cool, thanks! Yes, it's a known issue, I have described it in the blog post about using React with wallaby.js - http://dm.gl/2015/03/11/wallaby-react/:
Is it an issue for you that wallaby.js is using PhantomJs? We are planning to support more browser engines - #29, but it won't be 'headless'. |
No, it's not an issue actually. I'm using karma now. But was looking into jsdom lately. |
I'm currently trying to get Wallaby to work with decorators (new in babel 5.0, stage 1 proposal).
However, since Wallaby tries to read the file even before it runs the preprocessor and does not (yet) support this syntax (even though it handles type annotations), it can not handle the file and throws a syntax error.
Error:
Example:
Preprocessor section of wallaby.js:
And finally, the .babelrc:
Please let me know if you need more information or if there is anything else I can do to help.
The text was updated successfully, but these errors were encountered: