webpack-contrib / istanbul-instrumenter-loader

Istanbul Instrumenter Loader
MIT License
273 stars 65 forks source link

Getting error while running test with karma #58

Closed chinra02 closed 7 years ago

chinra02 commented 7 years ago

Hi,

I am getting below error while running test with karma, I am using angular 2 webpack starter configuration. Please help me resolving the issue.

23 05 2017 17:34:06.818:WARN [reporter]: SourceMap position not found for trace: undefined Chrome 50.0.2661 (Windows 10 0.0.0) ERROR Uncaught Error: Module build failed: SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (1:0) at Parser.pp$5.raise (S:\projects\trunk\util_angular2\node_modules\babylon\lib\index.js:4452:13) at Parser.pp$1.parseStatement (S:\projects\trunk\util_angular2\node_modules\babylon\lib\index.js:1881:16) at Parser.parseStatement (S:\projects\trunk\util_angular2\node_modules\babylon\lib\index.js:5804:22) at Parser.pp$1.parseBlockBody (S:\projects\trunk\util_angular2\node_modules\babylon\lib\index.js:2268:21) at Parser.pp$1.parseTopLevel (S:\projects\trunk\util_angular2\node_modules\babylon\lib\index.js:1778:8) at Parser.parse (S:\projects\trunk\util_angular2\node_modules\babylon\lib\index.js:1673:17) at Object.parse (S:\projects\trunk\util_angular2\node_modules\babylon\lib\index.js:7180:37) at Instrumenter.instrumentSync (S:\projects\trunk\util_angular2\node_modules\istanbul-lib-instrument\dist\instrumenter.js:121:31) at Instrumenter.instrument (S:\projects\trunk\util_angular2\node_modules\istanbul-lib-instrument\dist\instrumenter.js:176:32) at Object.module.exports (S:\projects\trunk\util_angular2\node_modules\istanbul-instrumenter-loader\index.js:25:25) at config/spec-bundle.js:69575

Thanks

Toltar commented 7 years ago

+1 I have the same error

mattlewis92 commented 7 years ago

To get this to work you need to enable esModules in the options you pass to the loader:

{
  test: /\.js$/,
  use: {
    loader: 'istanbul-instrumenter-loader',
    options: { esModules: true }
  }
}