dylanb / gulp-coverage

Gulp coverage reporting for Node.js that is independent of the test runner
MIT License
60 stars 12 forks source link

Unexpected reserved word: `class` #48

Closed ketsugi closed 8 years ago

ketsugi commented 8 years ago

I'm using gulp-coverage in my gulpfile like so:

gulp.task('test', () => {
  return gulp.src('test/**/*.js', {read: false})
    .pipe(cover.instrument({
      pattern: [`${srcDir}/**/*.js`, `!${srcDir}/configure.js`],
      debugDirectory: 'debug',
    }))
    .pipe(mocha({reporter: 'nyan'}))
    .pipe(cover.gather())
    .pipe(cover.format())
    .pipe(gulp.dest('reports'));
});

This the error I'm getting when running the task:

c:\Users\ketsu\Documents\Development\plexacious>gulp test
(node:14780) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[23:57:50] Using gulpfile c:\Users\ketsu\Documents\Development\plexacious\gulpfile.js
[23:57:50] Starting 'test'...

events.js:160
      throw er; // Unhandled 'error' event
      ^
 Error: Line 23: Unexpected reserved word
    at throwError (c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:1470:21)
    at throwUnexpected (c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:1518:17)
    at parsePrimaryExpression (c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:1832:16)
    at c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:3577:38
    at trackLeftHandSideExpressionAllowCall (c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:3483:61)
    at parsePostfixExpression (c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:1938:20)
    at c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:3577:38
    at parseUnaryExpression (c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:2001:16)
    at c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:3577:38
    at parseBinaryExpression (c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:2103:16)

In my source code file, line 23 is

class Plexacious extends EventEmitter {

If I replace this with a function declaration, the file seems to parse that line correctly. If I only remove the extends portion, I get the same error, so it seems that it's the class keyword itself that's causing the error.

Adding // cover: false to the end of the line does not help.

gulp-coverage version 0.3.38 instrumentjs version 0.0.2 is the one installed as a dependency of gulp-coverage, but I still get the same error after manually updating to 0.0.3.

dylanb commented 8 years ago

gulp-coverage does not support ES6 yet

ketsugi commented 8 years ago

Awww, darn. Thanks for the quick reply.