wallabyjs / atom-wallaby

Wallaby.js atom package starter
Other
57 stars 6 forks source link

Cannot run config #33

Closed gregorskii closed 8 years ago

gregorskii commented 8 years ago

Hi there,

I cannot run my wallaby.js config on Atom, it works on Intellij and Sublime text.

I get this error:

...node_modules/wallaby-webpack/index.js:30
class WebpackPostprocessor {
^^^^^
SyntaxError: Unexpected reserved word

It appears that atom-wallaby or wallabyjs itself is not first running a pass of babel on the wallabyjs config.

Here is my config:

'use strict';

require('babel-register');

const wallabyWebpack = require('wallaby-webpack');
const _gulpConfig = require('./gulp/gulp.config');
const _webpackConfig = require('./webpack.config.babel');
const path = require('path');

const babelConfig = fs.readFileSync('./.babelrc', 'utf-8');
const gulpConfig = _gulpConfig.default();
const webpackConfig = _webpackConfig.default(gulpConfig, 'test');

module.exports = (wallaby) => {
    let wallabyWebpackConfig = {};

    Object.assign(wallabyWebpackConfig, {
        module: webpackConfig.module,
        plugins: webpackConfig.plugins,
        resolve: {
            root: [
                path.join(wallaby.projectCacheDir, 'resources')
            ],
            scripts: 'scripts'
        }
    });

    //console.log(JSON.stringify(wallabyWebpackConfig, null, 4));

    let wallabyPostprocessor = wallabyWebpack(wallabyWebpackConfig);

    return {
        testFramework: 'jasmine',
        files: [
            {pattern: 'resources/scripts/**/*.js', load: false}
        ],
        tests: [
            {pattern: 'test/**/*\.spec.js', load: false}
        ],
        compilers: {
            '**/*.js': wallaby.compilers.babel(babelConfig)
        },
        postprocessor: wallabyPostprocessor,
        bootstrap: function() {
            // required to trigger test loading
            window.__moduleBundler.loadTests();
        }
    };
};

Let me know if you think this issue is with Wallaby itself. I will then ask this issue on the Wallaby github.

Thanks!

Greg

ArtemGovorov commented 8 years ago

Hello,

Wallaby doesn't use babel for its config, it relies on the features of the used node.js version. IntelliJ integration ships with embedded node 4.x, so it can run ES6 code in config and wallaby-webpack package (where the error comes from).

It looks like your Atom is using some older node.js version (system default one) that doesn't support ES6. You may download and install more recent node version as the default one, or side by side (using nvm or alike) and configure wallaby in Atom to use that version (one line in Atom init script).

Let me know if this helps.

gregorskii commented 8 years ago

Confirmed this is the fix. Appreciate it. I should have read the manual!