From 666a80fd023d1b6233eb846a3c2de21001dc7bc6 Mon Sep 17 00:00:00 2001 From: Juho Teperi Date: Sun, 22 Mar 2020 15:22:11 +0200 Subject: [PATCH] Enable test coverage reports --- .gitignore | 1 + circle.yml | 3 +++ package.json | 8 +++++--- test-environments/browser-cljsjs/test.sh | 2 +- test/runners/karma.conf.js | 18 ++++++++++++++++++ 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index f9b17af..af872d3 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ reagent.iml node_modules junit .shadow-cljs +coverage/ diff --git a/circle.yml b/circle.yml index 254b23b..07f9c3d 100644 --- a/circle.yml +++ b/circle.yml @@ -23,6 +23,9 @@ jobs: paths: - node_modules key: reagent-npm-{{ checksum "package.json" }} + - store_artifacts: + path: coverage + - run: bash <(curl -s https://codecov.io/bash) environment: NPM_CONFIG_LOGLEVEL: warn diff --git a/package.json b/package.json index 50865c9..bb826c7 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,12 @@ }, "devDependencies": { "gzip-size-cli": "3.0.0", - "karma": "3.1.1", - "karma-chrome-launcher": "2.2.0", + "karma": "4.4.1", + "karma-chrome-launcher": "3.1.0", "karma-cljs-test": "0.1.0", - "karma-junit-reporter": "1.2.0", + "karma-coverage": "https://github.com/karma-runner/karma-coverage.git#55aeead0934a39efbd9db0b575d416ab44cd8a12", + "karma-junit-reporter": "2.0.1", + "karma-sourcemap-loader": "^0.3.7", "md5-file": "4.0.0", "shadow-cljs": "2.8.83" } diff --git a/test-environments/browser-cljsjs/test.sh b/test-environments/browser-cljsjs/test.sh index 16e072c..b204423 100755 --- a/test-environments/browser-cljsjs/test.sh +++ b/test-environments/browser-cljsjs/test.sh @@ -1,5 +1,5 @@ #!/bin/bash set -ex rm -rf target/cljsbuild/test/ -lein doo chrome-headless test once +COVERAGE=1 lein doo chrome-headless test once test -f target/cljsbuild/test/out/cljsjs/react/development/react.inc.js diff --git a/test/runners/karma.conf.js b/test/runners/karma.conf.js index 147bc35..cc82cfc 100644 --- a/test/runners/karma.conf.js +++ b/test/runners/karma.conf.js @@ -24,5 +24,23 @@ module.exports = function(config) { useBrowserName: false // add browser name to report and classes names }; + if (process.env.COVERAGE) { + configData.reporters = ['dots', 'junit', 'coverage']; + + configData.preprocessors = { + 'target/cljsbuild/test/out/reagent/**/!(*_test).js': ['sourcemap', 'coverage'], + }; + + configData.coverageReporter = { + reporters: [ + {type: 'html'}, + {type: 'lcovonly'}, + ], + dir: 'coverage', + subdir: '.', + includeAllSources: true, + }; + } + config.set(configData); };