chore(project): add test coverage

* monitor coverage via codecov
* run coverage locally via COVERAGE=1 npm test
This commit is contained in:
Nico Rehwaldt 2018-10-01 10:45:18 +02:00 committed by merge-me[bot]
parent 350a5ab75e
commit f99a0a9609
5 changed files with 38 additions and 7 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
node_modules/
dist/
coverage/
.idea
*.iml
.DS_Store

View File

@ -10,7 +10,8 @@ jobs:
addons:
firefox: 'latest-esr'
script:
- TEST_BROWSERS=Firefox,PhantomJS xvfb-run npm run all
- COVERAGE=1 TEST_BROWSERS=Firefox,PhantomJS xvfb-run npm run all
- codecov
- stage: update integration test
script: './tasks/stages/update-integration-test'
- stage: update examples

View File

@ -41,14 +41,17 @@
"devDependencies": {
"chai": "^4.1.2",
"chai-match": "^1.1.1",
"codecov": "^3.1.0",
"cpx": "^1.5.0",
"del": "^3.0.0",
"eslint": "^4.19.0",
"eslint-plugin-bpmn-io": "^0.5.2",
"execa": "^0.8.0",
"istanbul-instrumenter-loader": "^3.0.1",
"jsondiffpatch": "^0.1.26",
"karma": "^2.0.2",
"karma": "^2.0.5",
"karma-chrome-launcher": "^2.1.1",
"karma-coverage": "^1.1.2",
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^1.0.1",
"karma-ie-launcher": "^1.0.0",

7
test/all.js Normal file
View File

@ -0,0 +1,7 @@
var allTests = require.context('.', true, /(spec|integration).*Spec\.js$/);
allTests.keys().forEach(allTests);
var allSources = require.context('../lib', true, /.*\.js$/);
allSources.keys().forEach(allSources);

View File

@ -1,3 +1,5 @@
var coverage = process.env.COVERAGE;
var path = require('path');
var basePath = '../../';
@ -25,6 +27,8 @@ var browsers =
return browser;
});
var suite = coverage ? 'test/all.js' : 'test/suite.js';
module.exports = function(karma) {
karma.set({
@ -37,14 +41,14 @@ module.exports = function(karma) {
],
files: [
'test/suite.js'
suite
],
preprocessors: {
'test/suite.js': [ 'webpack', 'env' ]
[ suite ]: [ 'webpack', 'env' ]
},
reporters: [ 'spec' ],
reporters: [ 'spec' ].concat(coverage ? 'coverage' : []),
customLaunchers: {
ChromeHeadless_Linux: {
@ -57,6 +61,12 @@ module.exports = function(karma) {
}
},
coverageReporter: {
reporters: [
{ type: 'lcov', subdir: '.' }
]
},
browsers: browsers,
browserNoActivityTimeout: 30000,
@ -64,7 +74,6 @@ module.exports = function(karma) {
singleRun: true,
autoWatch: false,
webpack: {
mode: 'development',
module: {
@ -73,7 +82,17 @@ module.exports = function(karma) {
test: /\.css|\.bpmn$/,
use: 'raw-loader'
}
]
].concat(coverage ?
{
test: /\.js$/,
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
},
include: /lib\.*/,
exclude: /node_modules/
} : []
)
},
resolve: {
mainFields: [