-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathkarma.conf.js
120 lines (108 loc) · 3.28 KB
/
karma.conf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const coverage = process.env.COVERAGE;
const path = require('path');
const { DefinePlugin, NormalModuleReplacementPlugin } = require('webpack');
const basePath = '.';
const absoluteBasePath = path.resolve(path.join(__dirname, basePath));
module.exports = function (karma) {
karma.set({
frameworks: ['webpack', 'mocha', 'sinon-chai'],
files: ['test/spec/**/*Spec.js'],
reporters: ['dots'],
preprocessors: {
'test/spec/**/*Spec.js': ['webpack', 'env'],
},
browsers: ['ChromeHeadless'],
browserNoActivityTimeout: 30000,
singleRun: true,
autoWatch: false,
webpack: {
mode: 'development',
module: {
rules: [
{
test: /\.(css|bpmn)$/,
use: 'raw-loader',
},
{
test: /\.m?jsx?$/,
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: {
extensions: ['', '.js', '.jsx', '.tsx'],
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',
},
});
};