diff --git a/build/karma.config.js b/build/karma.config.js index 701281df0..973d9c3aa 100644 --- a/build/karma.config.js +++ b/build/karma.config.js @@ -3,14 +3,25 @@ const webpackConfig = require('./webpack.config') const TEST_BUNDLER = './tests/test-bundler.js' +webpackConfig.module.rules.push({ + enforce: 'post', + test: /\.js$/, + loader: 'istanbul-instrumenter-loader', + query: { + esModules: true + }, + exclude: /(tests|node_modules|\.spec\.js$)/, +}) + const karmaConfig = { basePath: '../', browsers: ['PhantomJS'], singleRun: !argv.watch, - coverageReporter: { - reporters: [ - { type: 'text-summary' }, - ], + coverageIstanbulReporter: { + reports: argv.watch ? ['text-summary'] : ['html', 'lcovonly', 'text-summary'], + dir: 'build/coverage', + fixWebpackSourcePaths: true, + skipFilesWithNoCoverage: false }, files: [{ pattern : TEST_BUNDLER, @@ -19,7 +30,7 @@ const karmaConfig = { included : true }], frameworks: ['mocha'], - reporters: ['mocha'], + reporters: ['mocha', 'coverage-istanbul'], preprocessors: { [TEST_BUNDLER]: ['webpack'], }, diff --git a/package.json b/package.json index 582205025..5f151b978 100644 --- a/package.json +++ b/package.json @@ -70,8 +70,9 @@ "file-loader": "^0.11.1", "fs-extra": "^3.0.1", "html-webpack-plugin": "^2.24.1", + "istanbul-instrumenter-loader": "^2.0.0", "karma": "^1.7.0", - "karma-coverage": "^1.1.1", + "karma-coverage-istanbul-reporter": "^1.3.0", "karma-mocha": "^1.3.0", "karma-mocha-reporter": "^2.2.1", "karma-phantomjs-launcher": "^1.0.4", diff --git a/tests/test-bundler.js b/tests/test-bundler.js index 755b4ee72..55e939439 100644 --- a/tests/test-bundler.js +++ b/tests/test-bundler.js @@ -37,4 +37,7 @@ const changedTests = allTests.filter(path => { return __karmaWebpackManifest__.indexOf(path) !== -1 }) +const componentsContext = require.context('./../src', true, /\.(js)$/) +componentsContext.keys().forEach(componentsContext) + ;(changedTests.length ? changedTests : allTests).forEach(testsContext)