2017-08-12 104 views
0

PhantomJS newb在這裏,試圖與Karma一起使用PhantomJS,以便我可以在Jenkins上運行瀏覽器測試。支持與PhantomJS的JS運行時

我得到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 

使用讓變量聲明,像這樣的時候:

let handlePageRequest = {}; 

我怎麼能告訴PhantomJS解釋的JavaScript例如Chrome或Mozilla會的最新版本?

回答

0

我剛剛通過Babel對代碼進行了優化和轉換,現在它工作正常,我猜。

這是我用來transpile和優化:

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 
    ); 

});