diff --git a/.gitignore b/.gitignore index 2dfbfc3697..c38cba70da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /build/ -/node_modules/ +/coverage/ /dist/ +/node_modules/ diff --git a/.travis.yml b/.travis.yml index 173b2289d0..09c0729eb7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,8 @@ cache: before_script: - rm src/ol/renderer/webgl/*shader.js script: make ci +after_success: +- cat coverage/lcov.info | coveralls branches: only: - master diff --git a/package.json b/package.json index 987acd4c01..238e492a3c 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "jquery": "3.2.1", "jscodeshift": "^0.3.30", "karma": "^1.7.0", + "karma-coverage": "^1.1.1", "karma-chrome-launcher": "^2.1.1", "karma-firefox-launcher": "^1.0.1", "karma-mocha": "^1.3.0", diff --git a/test/karma.config.js b/test/karma.config.js index 3dd92e325a..0d7e250245 100644 --- a/test/karma.config.js +++ b/test/karma.config.js @@ -49,6 +49,25 @@ module.exports = function(karma) { proxies: { '/rendering/': '/base/rendering/', '/spec/': '/base/spec/' + }, + preprocessors: { + // source files, that you wanna generate coverage for + // do not include tests or libraries + // (these files will be instrumented by Istanbul) + '../src/**/*.js': ['coverage'] + }, + reporters: ['progress', 'coverage'], + coverageReporter: { + reporters: [ + { + type: 'lcov', // produces HTML output and lcov + dir: '../coverage/', + subdir: '.' + }, + { + type: 'text-summary' // prints the textual summary to the terminal + } + ] } }); @@ -91,11 +110,23 @@ module.exports = function(karma) { username: 'openlayers', accessKey: process.env.SAUCE_ACCESS_KEY }, - reporters: ['dots', 'saucelabs'], + reporters: ['dots', 'saucelabs', 'coverage'], captureTimeout: 240000, browserNoActivityTimeout: 240000, customLaunchers: customLaunchers, - browsers: Object.keys(customLaunchers) + browsers: Object.keys(customLaunchers), + coverageReporter: { + reporters: [ + { + type: 'lcovonly', // that's enough for coveralls, no HTML + dir: '../coverage/', + subdir: '.' + }, + { + type: 'text-summary' // prints the textual summary to the terminal + } + ] + } }); } else { karma.set({ diff --git a/test/test-extensions.js b/test/test-extensions.js index a3d45294fb..6811091eeb 100644 --- a/test/test-extensions.js +++ b/test/test-extensions.js @@ -502,7 +502,7 @@ goog.require('ol.renderer.webgl.Map'); } return { describe: features[key] ? global.describe : global.xdescribe, - it: features[key] ? global.id : global.xit + it: features[key] ? global.it : global.xit }; };