How can I 'force' ALL karma test to fail if an eslint error is found?

非 Y 不嫁゛ 提交于 2019-12-24 08:29:48

问题


I have found that sometimes people do not realise they have linting errors in their tests when they run them since they are show before the test progress/information.

Is there any configuration which will cause ALL tests to fail if any of the tests have any linting errors?

I am using mocha with karma.

Thanks.


回答1:


Make the ESLint execution a part of the grunt or gulp or "npm" task (whichever you use). For instance, when we run grunt test, first the ESLint is executed and then karma. If there are any errors or warnings produced by ESLint the task would fail early.




回答2:


Inside you webpack config, setup fail option for eslint like this

module.exports = {
  entry: "...",
  module: {
    // ...
  },
  eslint: {
    failOnError: true
  }
}

This would fail the build.

Doc ref: https://github.com/MoOx/eslint-loader#failonerror-default-false



来源:https://stackoverflow.com/questions/39229441/how-can-i-force-all-karma-test-to-fail-if-an-eslint-error-is-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!