Update karma and webpack config

This commit is contained in:
Bartek Fabiszewski 2019-12-19 23:04:12 +01:00
parent 01d86aa6dd
commit a38171cf2d
5 changed files with 918 additions and 712 deletions

View File

@ -3,36 +3,40 @@
process = require('process'); process = require('process');
process.env.CHROME_BIN = require('puppeteer').executablePath(); process.env.CHROME_BIN = require('puppeteer').executablePath();
const preprocessors = {}; const path = require('path');
const reporters = [ 'progress' ];
// don't preprocess files on debug run // don't preprocess files on debug run
if (!process.env._INTELLIJ_KARMA_INTERNAL_PARAMETER_debug && !process.argv.includes('--debug')) { // if (!process.env._INTELLIJ_KARMA_INTERNAL_PARAMETER_debug && !process.argv.includes('--debug')) {
preprocessors['src/**/*.js'] = 'karma-coverage-istanbul-instrumenter'; // reporters.push('coverage-istanbul');
reporters.push('coverage-istanbul'); // }
}
module.exports = function(config) { module.exports = function(config) {
config.set({ config.set({
basePath: 'js/', basePath: 'js/',
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: [ 'jasmine' ], frameworks: [ 'jasmine' ],
// list of files / patterns to load in the browser
files: [ files: [
{ pattern: 'test/*.test.js', type: 'module' }, { pattern: 'test/*.test.js', type: 'module' },
{ pattern: 'test/*.stub.js', type: 'module', included: false }, { pattern: 'test/*.stub.js', type: 'module', included: false },
{ pattern: 'src/**/*.js', type: 'module', included: false }, { pattern: 'test/helpers/*.js', type: 'module', included: false },
{ pattern: 'test/openlayers.bundle.js', type: 'js', included: true } { pattern: 'test/openlayers.bundle.js', type: 'js', included: true },
{ pattern: 'src/**/*.js', type: 'module', included: false }
], ],
// list of files / patterns to exclude
exclude: [], exclude: [],
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: {
preprocessors: preprocessors, 'test/*.test.js': [ 'webpack', 'sourcemap' ],
coverageIstanbulInstrumenter: { 'test/helpers/*.js': [ 'webpack', 'sourcemap' ],
esModules: true 'src/**/*.js': [ 'sourcemap' ]
},
coverageIstanbulReporter: {
reports: [ 'html', 'text-summary', 'lcovonly' ],
dir: path.join(__dirname, 'coverage'),
fixWebpackSourcePaths: true,
'report-config': {
html: { outdir: 'html' }
}
}, },
// possible values: 'dots', 'progress' // possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter reporters: [ 'progress', 'coverage-istanbul' ],
reporters: reporters,
// web server port // web server port
port: 9876, port: 9876,
// enable / disable colors in the output (reporters and logs) // enable / disable colors in the output (reporters and logs)
@ -48,6 +52,27 @@ module.exports = function(config) {
// if true, Karma captures browsers, runs the tests and exits // if true, Karma captures browsers, runs the tests and exits
singleRun: true, singleRun: true,
// how many browser should be started simultaneous // how many browser should be started simultaneous
concurrency: Infinity concurrency: Infinity,
// webpack
webpack: {
mode: 'development',
devtool: 'inline-source-map',
watch: true,
module: {
rules: [
{
test: /\.js$/,
include: path.resolve('js/src/'),
use: {
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
}
}
]
}
},
webpackMiddleware: {
noInfo: true
}
}) })
}; };

1507
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,33 +15,37 @@
"author": "Bartek Fabiszewski", "author": "Bartek Fabiszewski",
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.7.4", "@babel/cli": "^7.7.5",
"@babel/core": "^7.7.4", "@babel/core": "^7.7.5",
"@babel/plugin-transform-runtime": "^7.7.4", "@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.4", "@babel/preset-env": "^7.7.6",
"babel-eslint": "^10.0.3", "babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6", "babel-loader": "^8.0.6",
"browserlist": "^1.0.1", "browserlist": "^1.0.1",
"clean-webpack-plugin": "^3.0.0", "clean-webpack-plugin": "^3.0.0",
"core-js": "^3.4.2", "core-js": "^3.5.0",
"eslint": "^6.7.1", "eslint": "^6.7.2",
"eslint-plugin-import": "^2.18.2", "eslint-plugin-import": "^2.19.1",
"eslint-plugin-jasmine": "^4.1.0", "eslint-plugin-jasmine": "^4.1.0",
"istanbul-instrumenter-loader": "^3.0.1",
"jasmine": "^3.5.0", "jasmine": "^3.5.0",
"karma": "^4.4.1", "karma": "^4.4.1",
"karma-chrome-launcher": "^3.1.0", "karma-chrome-launcher": "^3.1.0",
"karma-coverage-istanbul-instrumenter": "^1.0.1", "karma-coverage-istanbul-instrumenter": "^1.0.1",
"karma-coverage-istanbul-reporter": "^2.1.1", "karma-coverage-istanbul-reporter": "^2.1.1",
"karma-jasmine": "^2.0.1", "karma-jasmine": "^2.0.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^4.0.2",
"puppeteer": "^2.0.0", "puppeteer": "^2.0.0",
"regenerator-runtime": "^0.13.3", "regenerator-runtime": "^0.13.3",
"webpack": "^4.41.2", "webpack": "^4.41.3",
"webpack-cli": "^3.3.10", "webpack-cli": "^3.3.10",
"webpack-merge": "^4.2.2" "webpack-merge": "^4.2.2"
}, },
"dependencies": { "dependencies": {
"@babel/runtime": "^7.7.4", "@babel/runtime": "^7.7.6",
"babel-runtime": "^6.26.0", "chartist": "^0.11.4",
"chartist-plugin-axistitle": "0.0.4",
"ol": "^6.1.1" "ol": "^6.1.1"
}, },
"browserslist": [ "browserslist": [

View File

@ -1,27 +0,0 @@
const path = require('path');
const MinifyPlugin = require('babel-minify-webpack-plugin');
module.exports = {
mode: 'production',
entry: './js/ulogger.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'js')
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
},
plugins: [
new MinifyPlugin()
]
};

View File

@ -3,6 +3,7 @@ const common = require('./webpack.common.js');
module.exports = merge(common, { module.exports = merge(common, {
mode: 'production', mode: 'production',
devtool: 'source-map',
module: { module: {
rules: [ rules: [
{ {