I would like to build my Javascript ES6 application using Gulp, Karma and PhantomJS but Phantom doesn't want to hear about any ES6 expression. I'm using PhantomJS v2.1 which is supposed to support ES6. I've also tried without browserify and babelify but no more success.
Any idea what am I missing here?
Here's my test code:
index.js:
"use strict";
const a = 5;
gulpfile.js:
'use strict';
var gulp = require('gulp');
var karma = require('gulp-karma');
function testClientCode() {
return gulp.src('index.js')
.pipe(karma({
configFile: 'karma.conf.js',
action: 'run'
}))
.on('error', function(err) {
throw err;
});
}
gulp.task('test-client', testClientCode);
karma.conf.js:
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['browserify'],
reporters: ['spec'],
port: 9876,
urlRoot: '/',
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['PhantomJS'],
singleRun: false,
browserify: {
debug: true,
transform: [ 'babelify' ]
}
});
};
And here's what I got when launching gulp:
[12:45:57] Using gulpfile /media/data/dev/testes6/gulpfile.js
[12:45:57] Starting 'test-client'...
[12:45:58] Starting Karma server...
27 05 2016 12:45:59.384:INFO [framework.browserify]: bundle built
27 05 2016 12:45:59.390:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
27 05 2016 12:45:59.397:INFO [launcher]: Starting browser PhantomJS
27 05 2016 12:45:59.587:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket /#eWK70DGTBDXsN94xAAAA with id 72822062
PhantomJS 2.1.1 (Linux 0.0.0) ERROR
SyntaxError: Unexpected token 'const'
at /media/data/dev/testes6/index.js:3
Thanks!