简体   繁体   中英

Karma tests with webpack

I am building js files by webpack. One of the loader is eslint . Whether eslint failed a build or not, Karma will try to start tests. Is there any way to prevent it and throw an error once?

Karma config looks like:

config.set({
   basePath: '',

   //...
   webpack: {
     module: {
        loaders: [
           {
              test: /\.js/,
              loaders: ['babel', 'eslint']
           }
        ]
        //...
    }
    //...
})

I don't think there's a good way, no. Webpack isn't a task runner, loaders are meant to transform source. eslint as a loader is sort of doing the linting as a side effect of the loading. I would just do the linting separately from the tests.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM