2022-06-08 20:31:17 +00:00
|
|
|
'use strict';
|
|
|
|
|
2022-06-28 19:30:50 +00:00
|
|
|
const coverage = process.env.COVERAGE;
|
|
|
|
const path = require('path');
|
|
|
|
const {
|
|
|
|
DefinePlugin,
|
|
|
|
NormalModuleReplacementPlugin
|
|
|
|
} = require('webpack');
|
|
|
|
const basePath = '.';
|
|
|
|
const absoluteBasePath = path.resolve(path.join(__dirname, basePath));
|
|
|
|
|
2022-06-08 20:31:17 +00:00
|
|
|
module.exports = function(karma) {
|
|
|
|
karma.set({
|
|
|
|
|
|
|
|
frameworks: [
|
2022-06-28 19:30:50 +00:00
|
|
|
'webpack',
|
2022-06-08 20:31:17 +00:00
|
|
|
'mocha',
|
|
|
|
'sinon-chai'
|
|
|
|
],
|
|
|
|
|
|
|
|
files: [
|
|
|
|
'test/spec/**/*Spec.js',
|
|
|
|
],
|
|
|
|
|
|
|
|
reporters: [ 'dots' ],
|
|
|
|
|
|
|
|
preprocessors: {
|
2022-06-28 19:30:50 +00:00
|
|
|
'test/spec/**/*Spec.js': [ 'webpack', 'env' ]
|
2022-06-08 20:31:17 +00:00
|
|
|
},
|
|
|
|
|
2022-07-01 17:01:52 +00:00
|
|
|
browsers: [ 'ChromeHeadless' ],
|
2022-06-08 20:31:17 +00:00
|
|
|
|
|
|
|
browserNoActivityTimeout: 30000,
|
|
|
|
|
|
|
|
singleRun: true,
|
|
|
|
autoWatch: false,
|
|
|
|
|
2022-06-28 19:30:50 +00:00
|
|
|
webpack: {
|
|
|
|
mode: 'development',
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(css|bpmn)$/,
|
|
|
|
use: 'raw-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.m?js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
plugins: [
|
|
|
|
[ '@babel/plugin-transform-react-jsx', {
|
|
|
|
'importSource': '@bpmn-io/properties-panel/preact',
|
|
|
|
'runtime': 'automatic'
|
|
|
|
} ]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.svg$/,
|
|
|
|
use: [ 'react-svg-loader' ]
|
|
|
|
}
|
|
|
|
].concat(coverage ?
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
use: {
|
|
|
|
loader: 'istanbul-instrumenter-loader',
|
|
|
|
options: { esModules: true }
|
|
|
|
},
|
|
|
|
enforce: 'post',
|
|
|
|
include: /src\.*/,
|
|
|
|
exclude: /node_modules/
|
|
|
|
} : []
|
|
|
|
)
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new DefinePlugin({
|
|
|
|
// @barmac: process.env has to be defined to make @testing-library/preact work
|
|
|
|
'process.env': {}
|
|
|
|
}),
|
|
|
|
new NormalModuleReplacementPlugin(
|
|
|
|
/^preact(\/[^/]+)?$/,
|
|
|
|
function(resource) {
|
|
|
|
|
|
|
|
const replMap = {
|
|
|
|
'preact/hooks': path.resolve('node_modules/@bpmn-io/properties-panel/preact/hooks/dist/hooks.module.js'),
|
|
|
|
'preact/jsx-runtime': path.resolve('node_modules/@bpmn-io/properties-panel/preact/jsx-runtime/dist/jsxRuntime.module.js'),
|
|
|
|
'preact': path.resolve('node_modules/@bpmn-io/properties-panel/preact/dist/preact.module.js')
|
|
|
|
};
|
|
|
|
|
|
|
|
const replacement = replMap[resource.request];
|
|
|
|
|
|
|
|
if (!replacement) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
resource.request = replacement;
|
|
|
|
}
|
|
|
|
),
|
|
|
|
new NormalModuleReplacementPlugin(
|
|
|
|
/^preact\/hooks/,
|
|
|
|
path.resolve('node_modules/@bpmn-io/properties-panel/preact/hooks/dist/hooks.module.js')
|
|
|
|
)
|
|
|
|
],
|
|
|
|
resolve: {
|
|
|
|
mainFields: [
|
|
|
|
'browser',
|
|
|
|
'module',
|
|
|
|
'main'
|
|
|
|
],
|
|
|
|
alias: {
|
|
|
|
'preact': '@bpmn-io/properties-panel/preact',
|
|
|
|
'react': '@bpmn-io/properties-panel/preact/compat',
|
|
|
|
'react-dom': '@bpmn-io/properties-panel/preact/compat'
|
|
|
|
},
|
|
|
|
modules: [
|
|
|
|
'node_modules',
|
|
|
|
absoluteBasePath
|
|
|
|
]
|
|
|
|
},
|
|
|
|
devtool: 'eval-source-map'
|
2022-06-08 20:31:17 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|