webpack-contrib / istanbul-instrumenter-loader

Istanbul Instrumenter Loader
MIT License
273 stars 65 forks source link

Improve readme file context being use #76

Closed sukrosono closed 6 years ago

sukrosono commented 6 years ago

I am new to webpack and istanbul, and about to add coverage to my lib. I just follow the tutorial and found this module here.

I am little bit confuse, do i have to run coverage under webpack or karma?

The readme file is quite nice, but i under options and above maintainer there are sample of file. But no note which file is that? Also on h3 with Babel no note which file is that.

I want submit a PR when that question is answered. Since two file (test/index.js, karma.conf.js) have note on which file should be edit.

michael-ciniawsky commented 6 years ago

Also on h3 with Babel no note which file is that

Both belong into webpack.config.js, feel definitely free to send a PR adding that :) by adding **webpack.config.js** above these two code blocks.

I'm not too familiar with this module myself and haven't used it in a while, but something like that should do the trick

webpack.config.js

const config = {
 ...,
 module: {
   rules: [
      {
        test: /\.js$|\.jsx$/,
        use: {
          loader: 'babel-loader',
        },
        exclude: /node_modules/,
      },
      {
        test: /\.js$|\.jsx$/,
        use: {
          loader: 'istanbul-instrumenter-loader',
          options: { esModules: true }
        },
        enforce: 'post', // <= make sure to run after the `babel-loader` 'rule'
        exclude: /(node_modules|\.spec\.js)$/,
      }
   ]
 }
}
sukrosono commented 6 years ago

Thank @michael-ciniawsky , but i still confuse with this question

I am little bit confuse, do i have to run coverage under webpack or karma?

michael-ciniawsky commented 6 years ago

In karma.conf.js

sukrosono commented 6 years ago

@michael-ciniawsky So sorry to brother you again, so in order to get the coverage i should run karma start karma.conf.js to get my coverage report? is that correct ?

sukrosono commented 6 years ago

:confused:

michael-ciniawsky commented 6 years ago

karma-webpack ? 🙃

sukrosono commented 6 years ago

karma webpack say

Use webpack to preprocess files in karma

so it main runtime is in karma right, not webpack. so in order to get the coverage i should run karma start karma.conf.js to get my coverage report? is that correct ?

michael-ciniawsky commented 6 years ago

Yep