-
Notifications
You must be signed in to change notification settings - Fork 3
/
karma.conf.js
80 lines (69 loc) · 1.95 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
const path = require('path');
const webpackConfig = require('./webpack.config');
delete webpackConfig.entry;
module.exports = config => {
const preprocessors = ['webpack', 'sourcemap'];
const settings = {
browsers: ['PhantomJS'], /* 'Chrome' */
frameworks: ['jasmine'],
// this is the entry file for all our tests.
files: ['test/index.js'],
// we will pass the entry file to webpack for bundling.
preprocessors: {
'test/index.js': preprocessors
},
// use the webpack config
webpack: webpackConfig,
// avoid walls of useless text
webpackMiddleware: {
noInfo: true
},
reporters: ['mocha'],
plugins: [
'karma-sourcemap-loader',
'karma-phantomjs-launcher',
'karma-chrome-launcher',
'karma-coverage',
'karma-jasmine',
'karma-mocha-reporter'
].concat(require('karma-webpack')),
colors: true,
logLevel: config.LOG_INFO,
singleRun: !config.tdd
};
if (config.coverage) {
// http://www.aptoma.com/es6-code-coverage-babel-jspm-karma-jasmine-istanbul/
settings.webpack.module.preLoaders = [
// transpile all files except testing sources with babel as usual
{
test: /\.js$/,
exclude: [
path.resolve('src/js/'),
path.resolve('node_modules/')
],
loader: 'babel'
},
// transpile and instrument only testing sources with babel-istanbul
{
test: /\.js$/,
include: path.resolve('src/js/'),
loader: 'babel-istanbul',
query: {
cacheDirectory: true,
embedSource: true,
noAutoWrap: true
}
}
];
settings.coverageReporter = {
instrumenters: { isparta: require('isparta') },
reporters: [
{ type: 'lcov', dir: './coverage' },
{ type: 'text', dir: './coverage' }
]
};
settings.reporters.push('coverage');
preprocessors.push('coverage');
}
config.set(settings);
};