diff --git a/.circleci/config.yml b/.circleci/config.yml index d3308d330c..22bf399fd6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,6 +27,10 @@ jobs: name: Run Tests command: npm test + - store_artifacts: + path: coverage/ + destination: coverage + - store_artifacts: path: rendering/cases/ destination: rendering diff --git a/package.json b/package.json index 58e54d922d..d96d680ee1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/karma.config.js b/test/karma.config.js index f7dd53a6d2..e1be311201 100644 --- a/test/karma.config.js +++ b/test/karma.config.js @@ -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'] - }); - } };