forked from enzymejs/enzyme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
118 lines (100 loc) · 2.77 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
/* eslint-disable no-var,prefer-arrow-callback,vars-on-top, import/no-extraneous-dependencies */
require('babel-register');
var IgnorePlugin = require('webpack').IgnorePlugin;
var is = require('./packages/enzyme-test-suite/test/_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 adapter16 = new IgnorePlugin(/enzyme-adapter-react-16$/);
var plugins = [
adapter13,
adapter14,
adapter154,
adapter15,
adapter16,
];
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')) {
plugins = plugins.filter(not(adapter16));
}
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/test/*.{jsx,js}',
],
exclude: [
'packages/enzyme-test-suite/test/_helpers/index.jsx',
],
browsers: [
process.env.TRAVIS ? 'Chrome_travis' : 'Chrome',
'Firefox',
],
preprocessors: {
'packages/enzyme-test-suite/test/*.{jsx,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,
},
});
};