Restore code coverage in Karma config

The transpiling step is done by babel instead of bublé now.
Bublé caused the istanbul instrumenter step to crash because of an
unexpected SourceMap object format.
This commit is contained in:
Olivier Guyot
2019-03-26 08:59:16 +01:00
parent d6485b1e94
commit d3e6f4c3b2
3 changed files with 33 additions and 27 deletions

View File

@@ -27,6 +27,10 @@ jobs:
name: Run Tests
command: npm test
- store_artifacts:
path: coverage/
destination: coverage
- store_artifacts:
path: rendering/cases/
destination: rendering

View File

@@ -41,12 +41,15 @@
"rbush": "2.0.2"
},
"devDependencies": {
"@babel/core": "^7.4.0",
"@babel/preset-env": "^7.4.2",
"@openlayers/eslint-plugin": "^4.0.0-beta.2",
"@types/arcgis-rest-api": "^10.4.4",
"@types/geojson": "^7946.0.7",
"@types/pbf": "^3.0.1",
"@types/rbush": "^2.0.2",
"@types/topojson-specification": "^1.0.1",
"babel-loader": "^8.0.5",
"buble": "^0.19.7",
"buble-loader": "^0.5.1",
"chaikin-smooth": "^1.0.4",
@@ -63,12 +66,14 @@
"handlebars": "4.1.2",
"html-to-image": "^0.1.0",
"istanbul": "0.4.5",
"istanbul-instrumenter-loader": "^3.0.1",
"jquery": "3.4.1",
"jsdoc": "3.5.5",
"jsdoc-plugin-typescript": "^1.0.8",
"karma": "^4.0.1",
"karma-chrome-launcher": "2.2.0",
"karma-coverage": "^1.1.2",
"karma-coverage-istanbul-reporter": "^2.0.5",
"karma-firefox-launcher": "^1.1.0",
"karma-mocha": "1.3.0",
"karma-sourcemap-loader": "^0.3.7",

View File

@@ -2,6 +2,7 @@ const path = require('path');
module.exports = function(karma) {
karma.set({
browsers: ['Chrome'],
browserDisconnectTolerance: 2,
frameworks: ['mocha'],
client: {
@@ -54,7 +55,12 @@ module.exports = function(karma) {
preprocessors: {
'**/*.js': ['webpack', 'sourcemap']
},
reporters: ['dots'],
reporters: ['dots', 'coverage-istanbul'],
coverageIstanbulReporter: {
reports: ['text-summary', 'html'],
dir: path.resolve(__dirname, '../coverage/'),
fixWebpackSourcePaths: true
},
webpack: {
devtool: 'inline-source-map',
mode: 'development',
@@ -63,8 +69,23 @@ module.exports = function(karma) {
{
test: /\.js$/,
use: {
loader: 'buble-loader'
}
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
},
include: path.resolve('src/ol/'),
exclude: path.resolve('node_modules/')
}, {
test: /\.js$/,
use: {
loader: 'istanbul-instrumenter-loader',
options: {
esModules: true
}
},
include: path.resolve('src/ol/'),
exclude: path.resolve('node_modules/')
}
]
}
@@ -75,28 +96,4 @@ module.exports = function(karma) {
});
process.env.CHROME_BIN = require('puppeteer').executablePath();
if (process.env.CIRCLECI) {
karma.set({
browsers: ['Chrome'],
preprocessors: {
'../src/**/*.js': ['coverage']
},
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({
browsers: ['Chrome']
});
}
};