Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

Commit

Permalink
1a test coverage measure (#112)
Browse files Browse the repository at this point in the history
* initial changes for covarege

* merge conflicts leftovers

* whitespace fix

* don't beautify test-coverage files

* add nyc for mocha tests coverage

* generate coverage badge in readme from two sources

* remove unused variable

* use nyc:cover grunt task in test
  • Loading branch information
magicznyleszek authored and MartijnR committed Aug 20, 2019
1 parent 398b917 commit 78fc6e8
Show file tree
Hide file tree
Showing 7 changed files with 1,226 additions and 38 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ setup/docker/secrets/*
setup/docker/redis_main_data/*
logs/submissions*
logs/logrotate
.nyc_output
test-coverage
coverage.shield.badge.md
22 changes: 19 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = grunt => {
const JS_INCLUDE = [ '**/*.js', '!**/node_modules/**', '!test/**/*.spec.js', '!public/js/build/*', '!test/client/config/karma.conf.js', '!docs/**' ];
const JS_INCLUDE = [ '**/*.js', '!**/node_modules/**', '!test/**/*.spec.js', '!public/js/build/*', '!test/client/config/karma.conf.js', '!docs/**', '!test-coverage/**' ];
const path = require( 'path' );
const nodeSass = require( 'node-sass' );
const bundles = require( './buildFiles' ).bundles;
Expand Down Expand Up @@ -78,6 +78,9 @@ module.exports = grunt => {
}
},
shell: {
buildReadmeBadge: {
command: 'node ./update-readme-with-shield-badge.js'
},
translation: {
command: [
'cd locales',
Expand Down Expand Up @@ -149,7 +152,6 @@ module.exports = grunt => {
karma: {
options: {
singleRun: true,
reporters: [ 'dots' ],
configFile: 'test/client/config/karma.conf.js'
},
headless: {
Expand All @@ -159,6 +161,20 @@ module.exports = grunt => {
browsers: [ 'Chrome', 'ChromeCanary', 'Firefox', 'Opera' /*,'Safari'*/ ],
}
},
nyc: {
cover: {
options: {
reporter: [
'html',
'text-summary',
'json'
],
reportDir: './test-coverage/server'
},
cmd: false,
args: [ 'grunt', 'mochaTest:all' ]
}
},
terser: {
options: {
// https://github.com/enketo/enketo-express/issues/72
Expand Down Expand Up @@ -256,7 +272,7 @@ module.exports = grunt => {
grunt.registerTask( 'js-dev', [ 'js' ] );
grunt.registerTask( 'js-ie11', [ 'js', 'shell:ie11polyfill', 'shell:babel', 'shell:browserify' ] );
grunt.registerTask( 'css', [ 'shell:clean-css', 'system-sass-variables:create', 'sass' ] );
grunt.registerTask( 'test', [ 'env:test', 'js', 'css', 'mochaTest:all', 'karma:headless', 'jsbeautifier:test', 'eslint' ] );
grunt.registerTask( 'test', [ 'env:test', 'js', 'css', 'nyc:cover', 'karma:headless', 'shell:buildReadmeBadge', 'jsbeautifier:test', 'eslint' ] );
grunt.registerTask( 'test-browser', [ 'env:test', 'css', 'client-config-file:create', 'karma:browsers' ] );
grunt.registerTask( 'develop', [ 'env:develop', 'i18next', 'js-dev', 'css', 'concurrent:develop' ] );
grunt.registerTask( 'develop-ie11', [ 'env:develop', 'i18next', 'js-ie11', 'css', 'concurrent:develop' ] );
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
![coverage-shield-badge-1](https://img.shields.io/badge/coverage-63.19%25-yellow.svg)
[![Build Status](https://travis-ci.org/enketo/enketo-express.svg?branch=master)](https://travis-ci.org/enketo/enketo-express) [![Dependency Status](https://david-dm.org/enketo/enketo-express.svg)](https://david-dm.org/enketo/enketo-express) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/609aaf6fa764454f901f1c8a427264ff)](https://www.codacy.com/app/martijnr/enketo-express?utm_source=github.com&utm_medium=referral&utm_content=enketo/enketo-express&utm_campaign=Badge_Grade)

Enketo Express
Expand Down
Loading

0 comments on commit 78fc6e8

Please sign in to comment.