Skip to content

Commit

Permalink
Add coverage report (date-fns#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
nanomosfet authored and elmomalmo committed Jul 12, 2019
1 parent 9630d48 commit c93cf26
Show file tree
Hide file tree
Showing 7 changed files with 2,958 additions and 2,772 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,3 +7,4 @@ dist
docs.json
.idea
.vscode
coverage
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -31,6 +31,8 @@ jobs:
- stage: deploy
if: tag IS present
script: ./scripts/release/release.sh
- stage: Coverage report
script: ./scripts/test/coverageReport.sh

cache: yarn

Expand Down
18 changes: 14 additions & 4 deletions config/karma.js
Expand Up @@ -131,11 +131,19 @@ function config(config) {
public: 'public'
},

coveageIstanbulReporter: {
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},

mochaReporter: {
output: 'minimal'
},

plugins: [
plugins: (process.env.COVERAGE_REPORT
? ['karma-coverage', 'karma-coverage-istanbul-reporter']
: []
).concat([
'karma-mocha',
'karma-mocha-reporter',
'karma-phantomjs-launcher',
Expand All @@ -148,13 +156,13 @@ function config(config) {
'karma-benchmark-reporter',
{ 'reporter:count': ['type', countReporter] },
{ 'reporter:benchmark-json': ['type', benchmarkJSONReporter] }
],
]),

customLaunchers: process.env.TEST_CROSS_BROWSER
? sauceLabsLaunchers
: process.env.TRAVIS
? travisLaunchers
: localLaunchers,
? travisLaunchers
: localLaunchers,
browsers: getBrowsersConfig(),
reporters: getReportersConfig()
})
Expand Down Expand Up @@ -205,6 +213,8 @@ function getReportersConfig() {
return ['dots', 'saucelabs', 'count']
} else if (process.env.TEST_BENCHMARK) {
return ['benchmark', 'benchmark-json']
} else if (process.env.COVERAGE_REPORT) {
return ['coverage-istanbul']
} else {
return ['mocha', 'count']
}
Expand Down
18 changes: 17 additions & 1 deletion config/webpack.js
Expand Up @@ -8,7 +8,23 @@ const config = {
entry: getEntryConfig(),
output: getOutputConfig(),
module: {
rules: [{ test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' }]
rules: [
{ test: /\.js$/, exclude: /node_modules/, use: 'babel-loader' }
].concat(
process.env.COVERAGE_REPORT
? [
{
test: /\.js$/,
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
},
enforce: 'post',
exclude: /node_modules|test.js$/
}
]
: []
)
}
}

Expand Down
7 changes: 7 additions & 0 deletions package.json
Expand Up @@ -47,19 +47,23 @@
"babel-preset-es2015": "^6.6.0",
"babel-preset-power-assert": "^1.0.0",
"cloc": "^2.2.0",
"coveralls": "^3.0.2",
"firebase": "^3.7.1",
"flow-bin": "0.84.0",
"fs-promise": "^1.0.0",
"glob-promise": "^2.0.0",
"gzip-size-cli": "^1.0.0",
"husky": "^1.0.0-rc.7",
"istanbul-instrumenter-loader": "^3.0.1",
"js-beautify": "^1.5.10",
"jsdoc-to-markdown": "leshakoss/jsdoc-to-markdown",
"karma": "^3.0.0",
"karma-benchmark": "^1.0.0",
"karma-benchmark-reporter": "^0.1.1",
"karma-chrome-launcher": "2.2",
"karma-cli": "^1.0.1",
"karma-coverage": "^1.1.2",
"karma-coverage-istanbul-reporter": "^2.0.4",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-phantomjs-launcher": "^1.0.4",
Expand All @@ -84,5 +88,8 @@
"webpack": "4",
"webpack-cli": "^3.1.2",
"world-countries": "^1.8.1"
},
"resolutions": {
"ajv": "6.8.1"
}
}
12 changes: 12 additions & 0 deletions scripts/test/coverageReport.sh
@@ -0,0 +1,12 @@
#!/bin/bash

# The script generates coverage report and uploads it to Coveralls.
#
# It's a part of the test process

set -ex

export PATH="$(yarn bin):$PATH"

env COVERAGE_REPORT=true yarn test --single-run
cat ./coverage/lcov.info | coveralls

0 comments on commit c93cf26

Please sign in to comment.