0

PhantomJS newb here, trying to use PhantomJS with Karma so that I can run browser tests on Jenkins.

I get this obvious error with PhantomJS

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  SyntaxError: Expected an identifier but found 'handlePageRequest' instead
  at public/app.js:45

when using let variable declaration like so:

 let handlePageRequest = {};

How can I tell PhantomJS to interpret JavaScript like the latest versions of Chrome or Mozilla would?

Alexander Mills
  • 90,741
  • 139
  • 482
  • 817

1 Answers1

0

I just optimized and transpiled our code with Babel, and now it works fine I guess.

This is what I used to transpile and optimize:

    gulp.task('bundle-prod', ['clean'], function (cb) {

      // this takes all the js files in public dir, except for those in public/lib
      // minifies them
      // concatenates them
      // then writes the concatenated file to app-production.js
      // so in production, all our angular.js javascript code is in one file

      pump([
          gulp.src(['public/**/*.js','!public/lib/**/*'], {}),
          babel({
            ignore: ['public/lib/**/*'],
            comments: false,
            minified: true,
            plugins: ['transform-remove-console'],
            presets: ['env']
          }),
          concat('public/dist/app-production.js'),
          gulp.dest('.')
        ],
        cb
      );

});
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817