This repository was archived by the owner on Oct 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkarma.config.js
More file actions
81 lines (77 loc) · 2.32 KB
/
karma.config.js
File metadata and controls
81 lines (77 loc) · 2.32 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
var argv = require('yargs').argv;
var path = require('path');
module.exports = function(config) {
config.set({
browsers: ['PhantomJS'],
singleRun: !argv.watch, // just run once by default
frameworks: ['mocha', 'chai'],
// npm i karma-spec-reporter --save-dev
// displays tests in a nice readable format
reporters: ['spec'],
// include some polyfills for babel and phantomjs
files: [
'./test/**/*spec.js' // specify files to watch for tests
],
preprocessors: {
// these files we want to be precompiled with webpack
// also run tests throug sourcemap for easier debugging
'./src/**/*.js': ['webpack', 'sourcemap'],
'./src/**/*.jsx': ['webpack', 'sourcemap'],
'./test/**/*.js': ['webpack', 'sourcemap']
},
webpack: {
devtool: 'inline-source-map',
resolve: {
// allow us to import components in tests like:
// import Example from 'components/Example';
root: path.resolve(__dirname, './src'),
// allow us to avoid including extension name
extensions: ['', '.js', '.jsx'],
// required for enzyme to work properly
alias: {
'sinon': 'sinon/pkg/sinon'
}
},
module: {
// don't run babel-loader through the sinon module
noParse: [
/node_modules\/sinon\//
],
// run babel loader for our tests
loaders: [
{
// make sure it can do both js and jsx
test: /\.jsx?$/,
exclude: path.resolve(__dirname, 'node_modules'),
loader: 'babel',
// following not needed if it is in the .babelrc file
query: {
presets: ['es2015', 'react']
}
},
],
},
// required for enzyme to work properly
externals: {
'jsdom': 'window',
'cheerio': 'window',
'react/addons': true,
'react/lib/ExecutionEnvironment': true,
'react/lib/ReactContext': true
},
},
webpackMiddleware: {
noInfo: true
},
// tell karma all the plugins we're going to be using
plugins: [
'karma-mocha',
'karma-chai',
'karma-webpack',
'karma-phantomjs-launcher',
'karma-spec-reporter',
'karma-sourcemap-loader',
'karma-babel-preprocessor'
]
});
};