-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathkarma.conf.js
More file actions
149 lines (134 loc) · 3.75 KB
/
karma.conf.js
File metadata and controls
149 lines (134 loc) · 3.75 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
var path = require('path');
module.exports = function(config) {
config.set(addCoverage({
frameworks: [ 'mocha' ],
browsers: [ 'chrome_without_security' ],
plugins: [
'karma-mocha',
'karma-sourcemap-loader',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-webpack',
],
customLaunchers: {
// if you want to use this (for CI or to debug a ScriptError), run karma
// with:
//
// karma start --browsers "chrome_without_security"
chrome_without_security: {
base: 'Chrome',
flags: [
'--no-default-browser-check',
'--no-first-run',
'--disable-default-apps',
'--disable-popup-blocking',
'--disable-translate',
// This is necessary in order to get useful error messages that
// happen outside of the test suites (e.g, script load errors).
//
// Without this flag, we get the dreaded "Script Error." message with
// no explanation, and that is due to the cross-origin policies (since
// karma loads our tests files using socket.io from another "origin").
//
// Additional reading:
//
// - https://github.com/karma-runner/karma/issues/543
// - http://stackoverflow.com/questions/5913978/cryptic-script-error-reported-in-javascript-in-chrome-and-firefox
// - https://bugs.webkit.org/show_bug.cgi?id=70574
// - https://groups.google.com/forum/#!topic/angular/VeqlVgUa6Wo
//
'--disable-web-security',
]
}
},
files: [
'test/index.js',
],
preprocessors: {
'test/index.js': [ 'webpack', 'sourcemap' ]
},
reporters: [ 'dots' ],
mochaReporter: {
ignoreSkipped: true
},
client: {
captureConsole: true,
mocha: {
reporter: 'html', // change Karma's debug.html to the mocha web reporter
ui: 'bdd'
}
},
webpack: {
devtool: 'eval',
entry: undefined,
context: path.resolve(__dirname, 'lib'),
resolve: {
alias: {
'react-drill': path.resolve(__dirname, 'lib/index.js'),
'test': path.resolve(__dirname, 'test'),
},
},
module: {
rules: [
{
test: /\.js$/,
include: [
path.resolve(__dirname, 'lib'),
path.resolve(__dirname, 'addons'),
],
exclude: [
/node_modules/
],
loader: 'babel-loader',
options: {
plugins: [
['babel-plugin-istanbul', {
exclude: [
'**/__tests__/',
'**/lib/dependencies/ReactTestUtils.js'
]
}]
]
}
},
{
test: /\.test\.js$|test\/.*\.js$/,
include: [
path.resolve(__dirname, 'lib'),
path.resolve(__dirname, 'test'),
path.resolve(__dirname, 'addons'),
],
exclude: [
/node_modules/
],
loader: 'babel-loader',
options: {
presets: ['babel-preset-react']
}
}
]
}
},
webpackMiddleware: {
noInfo: true
}
}));
};
function addCoverage(config) {
return Object.assign({}, config, {
plugins: (config.plugins || []).concat([
'karma-coverage',
]),
reporters: (config.reporters || []).concat([
'coverage',
]),
coverageReporter: {
dir: path.resolve(__dirname, 'coverage'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
],
}
})
}