-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
100 lines (88 loc) · 2.66 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
var path = require('path');
module.exports = function(config) {
config.set({
// use the PhantomJS browser
browsers: ['PhantomJS'],
// use the Jasmine testing framework
frameworks: ['jasmine'],
// files that Karma will server to the browser
files: [
// use Babel polyfill to emulate a full ES6 environment in PhantomJS
'node_modules/babel-polyfill/dist/polyfill.js',
// entry file for Webpack
'react/test/testHelper.js',
'node_modules/whatwg-fetch/fetch.js'
],
// before serving test/testHelper.js to the browser
preprocessors: {
'react/test/testHelper.js': [
// use karma-webpack to preprocess the file via webpack
'webpack',
// use karma-sourcemap-loader to utilize sourcemaps generated by webpack
'sourcemap'
]
},
// webpack configuration used by karma-webpack
webpack: {
// generate sourcemaps
devtool: 'eval-source-map',
// enzyme-specific setup
externals: {
'cheerio': 'window',
'react/addons': true,
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': true
},
module: {
loaders: [
// use babel-loader to transpile the test and src folders
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
// use isparta-loader for ES6 code coverage in the src folder
{
test: /\.jsx?$/,
exclude: /(node_modules|test)/,
loader: 'isparta-loader'
},
{
include: /\.json$/,
loader: 'json-loader'
}
]
},
// relative path starts out at the src folder when importing modules
resolve: {
modules: ['src', 'node_modules']
}
},
webpackMiddleware: {
// do not output webpack build information to the browser's console
noInfo: true
},
// test reporters that Karma should use
reporters: [
// use karma-spec-reporter to report results to the browser's console
'spec',
// use karma-coverage to report test coverage
'coverage'
],
// karma-spec-reporter configuration
specReporter: {
// remove meaningless stack trace when tests do not pass
maxLogLines: 1,
// do not print information about tests that are passing
suppressPassed: true
},
// karma-coverage configuration
coverageReporter: {
// output coverage results to the coverage folder in the project's root
dir: 'coverage',
subdir: '.',
// output coverage results as html
type: 'html'
}
})
}