Skip to content

Commit

Permalink
add code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann-S committed Mar 5, 2018
1 parent b7a549c commit e43f973
Show file tree
Hide file tree
Showing 5 changed files with 774 additions and 354 deletions.
7 changes: 6 additions & 1 deletion .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,10 @@ module.exports = {
plugins: [
process.env.PLUGINS && 'transform-es2015-modules-strip',
'@babel/proposal-object-rest-spread'
].filter(Boolean)
].filter(Boolean),
env: {
test: {
plugins: [ 'istanbul' ]
}
}
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,4 @@ twbsconfig.yml

# Folders to ignore
node_modules
js/coverage
27 changes: 22 additions & 5 deletions js/tests/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-env node */
/* eslint no-process-env: 0 */
const path = require('path')
const jsCoveragePath = path.resolve(__dirname, '../coverage')

module.exports = (config) => {
const jqueryFile = process.env.USE_OLD_JQUERY ? 'js/tests/vendor/jquery-1.9.1.min.js' : 'assets/js/vendor/jquery-slim.min.js'
Expand All @@ -11,18 +13,19 @@ module.exports = (config) => {
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-qunit',
'karma-detect-browsers'
'karma-detect-browsers',
'karma-coverage-istanbul-reporter'
],
// list of files / patterns to load in the browser
files: [
jqueryFile,
'assets/js/vendor/popper.min.js',
'js/dist/util.js',
'js/dist/tooltip.js',
'js/dist/!(util|index|tooltip).js', // include all of our js/dist files except util.js, index.js and tooltip.js
'js/coverage/dist/util.js',
'js/coverage/dist/tooltip.js',
'js/coverage/dist/!(util|index|tooltip).js', // include all of our js/dist files except util.js, index.js and tooltip.js
'js/tests/unit/*.js'
],
reporters: ['dots'],
reporters: ['dots', 'coverage-istanbul'],
port: 9876,
colors: true,
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
Expand All @@ -49,6 +52,20 @@ module.exports = (config) => {

throw new Error('Please install Firefox or Chrome')
}
},
coverageIstanbulReporter: {
dir: jsCoveragePath,
reports: ['lcov', 'text-summary'],
fixWebpackSourcePaths: true,
thresholds: {
emitWarning: true,
global: {
statements: 80,
lines: 80,
branches: 80,
functions: 80
}
}
}
})
}
Loading

0 comments on commit e43f973

Please sign in to comment.