add code coverage

This commit is contained in:
Johann-S 2018-03-02 14:15:20 +01:00
parent b7a549c8c3
commit e43f97304e
5 changed files with 766 additions and 346 deletions

View File

@ -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
.gitignore vendored
View File

@ -44,3 +44,4 @@ twbsconfig.yml
# Folders to ignore
node_modules
js/coverage

View File

@ -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'
@ -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
@ -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
}
}
}
})
}

1072
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -33,12 +33,13 @@
"js": "npm-run-all js-lint* js-compile js-minify",
"js-main": "npm-run-all js-lint js-compile js-minify",
"js-docs": "npm-run-all js-lint-docs js-minify-docs",
"js-lint": "eslint js/ build/",
"js-lint": "eslint js/src js/tests build/",
"js-lint-docs": "eslint assets/js/ docs/ sw.js",
"js-compile": "npm-run-all --parallel js-compile-*",
"js-compile-standalone": "rollup --environment BUNDLE:false --config build/rollup.config.js --sourcemap",
"js-compile-bundle": "rollup --environment BUNDLE:true --config build/rollup.config.js --sourcemap",
"js-compile-plugins": "cross-env PLUGINS=true babel js/src/ --out-dir js/dist/ --source-maps",
"js-compile-plugins-coverage": "cross-env PLUGINS=true NODE_ENV=test babel js/src/ --out-dir js/coverage/dist/ --source-maps",
"js-minify": "npm-run-all --parallel js-minify-*",
"js-minify-standalone": "uglifyjs --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/js/bootstrap.js.map,includeSources,url=bootstrap.min.js.map\" --output dist/js/bootstrap.min.js dist/js/bootstrap.js",
"js-minify-bundle": "uglifyjs --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/js/bootstrap.bundle.js.map,includeSources,url=bootstrap.bundle.min.js.map\" --output dist/js/bootstrap.bundle.min.js dist/js/bootstrap.bundle.js",
@ -90,6 +91,7 @@
"@babel/preset-env": "7.0.0-beta.40",
"autoprefixer": "^8.1.0",
"babel-eslint": "^8.2.2",
"babel-plugin-istanbul": "^4.1.5",
"babel-plugin-transform-es2015-modules-strip": "^0.1.1",
"bundlesize": "^0.16.0",
"clean-css-cli": "^4.1.11",
@ -101,6 +103,7 @@
"jsunitsaucelabs": "^1.3.0",
"karma": "^2.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "^1.4.1",
"karma-detect-browsers": "^2.2.6",
"karma-firefox-launcher": "^1.1.0",
"karma-qunit": "^1.2.1",