Skip to content

Commit e43f973

Browse files
committed
add code coverage
1 parent b7a549c commit e43f973

File tree

5 files changed

+774
-354
lines changed

5 files changed

+774
-354
lines changed

.babelrc.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,10 @@ module.exports = {
1212
plugins: [
1313
process.env.PLUGINS && 'transform-es2015-modules-strip',
1414
'@babel/proposal-object-rest-spread'
15-
].filter(Boolean)
15+
].filter(Boolean),
16+
env: {
17+
test: {
18+
plugins: [ 'istanbul' ]
19+
}
20+
}
1621
};

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,4 @@ twbsconfig.yml
4444

4545
# Folders to ignore
4646
node_modules
47+
js/coverage

js/tests/karma.conf.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* eslint-env node */
22
/* eslint no-process-env: 0 */
3+
const path = require('path')
4+
const jsCoveragePath = path.resolve(__dirname, '../coverage')
35

46
module.exports = (config) => {
57
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) => {
1113
'karma-chrome-launcher',
1214
'karma-firefox-launcher',
1315
'karma-qunit',
14-
'karma-detect-browsers'
16+
'karma-detect-browsers',
17+
'karma-coverage-istanbul-reporter'
1518
],
1619
// list of files / patterns to load in the browser
1720
files: [
1821
jqueryFile,
1922
'assets/js/vendor/popper.min.js',
20-
'js/dist/util.js',
21-
'js/dist/tooltip.js',
22-
'js/dist/!(util|index|tooltip).js', // include all of our js/dist files except util.js, index.js and tooltip.js
23+
'js/coverage/dist/util.js',
24+
'js/coverage/dist/tooltip.js',
25+
'js/coverage/dist/!(util|index|tooltip).js', // include all of our js/dist files except util.js, index.js and tooltip.js
2326
'js/tests/unit/*.js'
2427
],
25-
reporters: ['dots'],
28+
reporters: ['dots', 'coverage-istanbul'],
2629
port: 9876,
2730
colors: true,
2831
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
@@ -49,6 +52,20 @@ module.exports = (config) => {
4952

5053
throw new Error('Please install Firefox or Chrome')
5154
}
55+
},
56+
coverageIstanbulReporter: {
57+
dir: jsCoveragePath,
58+
reports: ['lcov', 'text-summary'],
59+
fixWebpackSourcePaths: true,
60+
thresholds: {
61+
emitWarning: true,
62+
global: {
63+
statements: 80,
64+
lines: 80,
65+
branches: 80,
66+
functions: 80
67+
}
68+
}
5269
}
5370
})
5471
}

0 commit comments

Comments
 (0)