-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathkarma.conf.js
More file actions
133 lines (114 loc) · 3.37 KB
/
Copy pathkarma.conf.js
File metadata and controls
133 lines (114 loc) · 3.37 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
/* eslint-disable no-var,prefer-arrow-callback,vars-on-top, import/no-extraneous-dependencies */
'use strict';
require('@babel/register');
var IgnorePlugin = require('webpack').IgnorePlugin;
var is = require('./packages/enzyme-test-suite/build/_helpers/version').is;
function getPlugins() {
const adapter13 = new IgnorePlugin(/enzyme-adapter-react-13$/);
const adapter14 = new IgnorePlugin(/enzyme-adapter-react-14$/);
const adapter154 = new IgnorePlugin(/enzyme-adapter-react-15\.4$/);
const adapter15 = new IgnorePlugin(/enzyme-adapter-react-15$/);
const adapter161 = new IgnorePlugin(/enzyme-adapter-react-16.1$/);
const adapter162 = new IgnorePlugin(/enzyme-adapter-react-16.2$/);
const adapter163 = new IgnorePlugin(/enzyme-adapter-react-16.3$/);
const adapter16 = new IgnorePlugin(/enzyme-adapter-react-16$/);
const adapter17 = new IgnorePlugin(/enzyme-adapter-react-17$/);
var plugins = [
adapter13,
adapter14,
adapter154,
adapter15,
adapter16,
adapter17,
];
function not(x) {
return function notPredicate(y) {
return y !== x;
};
}
// we want to ignore all of the adapters *except* the one we are currently using
if (is('0.13.x')) {
plugins = plugins.filter(not(adapter13));
} else if (is('0.14.x')) {
plugins = plugins.filter(not(adapter14));
} else if (is('^15.5.0')) {
plugins = plugins.filter(not(adapter15));
} else if (is('^15.0.0-0')) {
plugins = plugins.filter(not(adapter154));
} else if (is('~16.0.0-0 || ~16.1')) {
plugins = plugins.filter(not(adapter161));
} else if (is('~16.2')) {
plugins = plugins.filter(not(adapter162));
} else if (is('~16.3.0-0')) {
plugins = plugins.filter(not(adapter163));
} else if (is('^16.4.0-0')) {
plugins = plugins.filter(not(adapter16));
} else if (is('^17.0.0')) {
plugins = plugins.filter(not(adapter17));
}
return plugins;
}
module.exports = function karma(config) {
config.set({
basePath: '.',
plugins: [
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-mocha',
'karma-webpack',
'karma-sourcemap-loader',
],
customLaunchers: {
Chrome_travis: {
base: 'Chrome',
flags: ['--no-sandbox'],
},
},
frameworks: ['mocha'],
reporters: ['dots'],
files: [
'packages/enzyme-test-suite/build/*.js',
],
exclude: [
'packages/enzyme-test-suite/build/_helpers/index.js',
],
browsers: [
process.env.TRAVIS ? 'Chrome_travis' : 'Chrome',
'Firefox',
],
preprocessors: {
'packages/enzyme-test-suite/build/*.js': ['webpack', 'sourcemap'],
},
webpack: {
devtool: 'inline-source-map',
resolve: {
extensions: ['', '.js', '.jsx', '.json'],
alias: {
// dynamic require calls in sinon confuse webpack so we ignore it
sinon: 'sinon/pkg/sinon',
},
},
module: {
noParse: [
// dynamic require calls in sinon confuse webpack so we ignore it
/node_modules\/sinon\//,
],
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.json$/,
loader: 'json-loader',
},
],
},
plugins: getPlugins(),
},
webpackServer: {
noInfo: true,
},
});
};