-
Notifications
You must be signed in to change notification settings - Fork 39
/
karma.config.js
92 lines (87 loc) · 2.37 KB
/
karma.config.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
const path = require('path');
const webpack = require('webpack');
const args = require('yargs').argv;
const unitTestEntry = 'source/test/unit/helper.js';
// run multiple times in watch mode
const singleRun = !args.watch;
// use phantomjs in watch mode
const browser = (args.watch || args.ci) ? 'PhantomJS' : 'Chrome';
// load babel polyfill for phantomjs
const files = browser === 'PhantomJS' ? [
'node_modules/babel-core/browser-polyfill.js',
unitTestEntry
] : [
unitTestEntry
];
const include = [
path.resolve('./source')
];
const preLoaders = [
// Process test code with Babel
{test: /\.spec\.js$/, loader: 'babel', include},
// Process all non-test code with Isparta
{test: /\.js$/, loader: 'isparta', include, exclude: /\.spec\.js$/}
];
const loaders = [
{test: /\.styl$/, loader: 'style!css!stylus'},
{test: /\.jade$/, loader: 'jade'},
{test: /\.(png|jpg)$/, loader: 'null'}
];
const processors = {};
processors[unitTestEntry] = ['webpack', 'sourcemap'];
processors['source/app/**/*.js'] = ['webpack', 'sourcemap'];
// for watch mode, only show text coverage
const reporters = args.watch ? [
'mocha', 'coverage'
] : [
'mocha', 'coverage', 'junit'
];
const coverageReporters = args.watch ? [
{type: 'text-summary'}
] : [
{type: 'lcov', subdir: '.'},
{type: 'text-summary'}
];
module.exports = (config) => {
config.set({
basePath: '.',
frameworks: ['jasmine'],
exclude: [],
files,
webpack: {
devtool: 'inline-source-map',
module: {
preLoaders,
loaders
},
cache: true,
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
})
]
},
webpackMiddleware: {
stats: {
chunkModules: false,
colors: true
}
},
preprocessors: processors,
reporters,
coverageReporter: {
dir: 'source/test/unit/results/coverage',
reporters: coverageReporters
},
junitReporter: {
outputDir: 'source/test/unit/results/junit'
},
reportSlowerThan: 500,
singleRun,
browsers: [
browser
]
});
};