kasaharu/triangle

コードカバレッジの設定改善

Closed this issue · 2 comments

レポート出力

変更内容

@@ -17,7 +17,7 @@ module.exports = function (config) {
     },
     coverageIstanbulReporter: {
       dir: require('path').join(__dirname, '../../coverage'),
-      reports: ['html', 'lcovonly'],
+      reports: ['html', 'lcovonly', 'text-summary'],
       fixWebpackSourcePaths: true
     },
     reporters: ['progress', 'kjhtml'],
@@ -28,4 +28,4 @@ module.exports = function (config) {
     browsers: ['Chrome'],
     singleRun: false

test result

$ yarn test-gh --watch=false --code-coverage
yarn run v1.7.0
$ ng test gh-render --watch=false --code-coverage
 10% building modules 1/1 modules 0 active(node:8736) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
27 07 2018 10:36:23.403:INFO [karma]: Karma v2.0.5 server started at http://0.0.0.0:9876/
27 07 2018 10:36:23.404:INFO [launcher]: Launching browser Chrome with unlimited concurrency
27 07 2018 10:36:23.423:INFO [launcher]: Starting browser Chrome
27 07 2018 10:36:29.329:INFO [Chrome 68.0.3440 (Mac OS X 10.13.6)]: Connected on socket IlZyOcuyOFAojUYjAAAA with id 43348253
Chrome 68.0.3440 (Mac OS X 10.13.6): Executed 7 of 7 SUCCESS (0.3 secs / 0.26 secs)
TOTAL: 7 SUCCESS

=============================== Coverage summary ===============================
Statements   : 94.62% ( 88/93 )
Branches     : 56.86% ( 58/102 )
Functions    : 94.44% ( 17/18 )
Lines        : 100% ( 74/74 )
================================================================================
TOTAL: 7 SUCCESS
TOTAL: 7 SUCCESS
✨  Done in 38.36s.

閾値の設定

変更内容

diff --git a/projects/gh-render/karma.conf.js b/projects/gh-render/karma.conf.js
index bab68de..753b69f 100644
--- a/projects/gh-render/karma.conf.js
+++ b/projects/gh-render/karma.conf.js
@@ -18,7 +18,15 @@ module.exports = function (config) {
     coverageIstanbulReporter: {
       dir: require('path').join(__dirname, '../../coverage'),
       reports: ['html', 'lcovonly', 'text-summary'],
-      fixWebpackSourcePaths: true
+      fixWebpackSourcePaths: true,
+      thresholds: {
+        global: {
+          statements: 100,
+          lines: 100,
+          branches: 100,
+          functions: 100,
+        }
+      }
     },
     reporters: ['progress', 'kjhtml'],
     port: 9876,

テスト結果

$ yarn test-gh --watch=false --code-coverage
yarn run v1.7.0
$ ng test gh-render --watch=false --code-coverage
 10% building modules 1/1 modules 0 active(node:10182) DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead
27 07 2018 10:50:38.327:INFO [karma]: Karma v2.0.5 server started at http://0.0.0.0:9876/
27 07 2018 10:50:38.328:INFO [launcher]: Launching browser Chrome with unlimited concurrency
27 07 2018 10:50:38.361:INFO [launcher]: Starting browser Chrome
27 07 2018 10:50:44.167:INFO [Chrome 68.0.3440 (Mac OS X 10.13.6)]: Connected on socket nsQUcfp84xY9hJbDAAAA with id 41260592
Chrome 68.0.3440 (Mac OS X 10.13.6): Executed 7 of 7 SUCCESS (0.3 secs / 0.256 secs)
TOTAL: 7 SUCCESS

=============================== Coverage summary ===============================
Statements   : 94.62% ( 88/93 )
Branches     : 56.86% ( 58/102 )
Functions    : 94.44% ( 17/18 )
Lines        : 100% ( 74/74 )
================================================================================
27 07 2018 10:50:45.579:ERROR [reporter.coverage-istanbul]: Coverage for statements (94.62%) does not meet global threshold (100%)
27 07 2018 10:50:45.579:ERROR [reporter.coverage-istanbul]: Coverage for branches (56.86%) does not meet global threshold (100%)
27 07 2018 10:50:45.579:ERROR [reporter.coverage-istanbul]: Coverage for functions (94.44%) does not meet global threshold (100%)
TOTAL: 7 SUCCESS
TOTAL: 7 SUCCESS
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.