-
Notifications
You must be signed in to change notification settings - Fork 8
/
karma.conf.js
103 lines (93 loc) · 2.5 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
101
102
103
/*global __dirname, module, process */
var path = require('path');
var babelSettings = {
presets: ['es2015'],
// For testing, especially useful for angular-style modules in the
// process of being converted
plugins: [
'transform-flow-strip-types',
'transform-runtime',
'lodash',
'rewire',
],
};
var browsers = ['PhantomJS'];
if (process.env.TEST_ENV === 'BROWSERS') {
browsers.push('Firefox');
}
var webpackConfig = require('./webpack.config.js');
var webpack = require('webpack');
var DefinePlugin = webpack.DefinePlugin;
function toPath(p) {
return path.resolve(path.join(__dirname, p));
}
module.exports = function (config) {
config.set({
browsers: browsers,
frameworks: ['mocha', 'chai-sinon'],
singleRun: true,
reporters: ['progress', 'coverage'],
files: [
'node_modules/babel-polyfill/dist/polyfill.js',
'src/app/app.js',
'node_modules/angular-mocks/angular-mocks.js',
'test/karma/**/*.js',
],
preprocessors: {
'src/app/**/*.js': ['webpack', 'sourcemap'],
'test/karma/**/*.js': ['webpack', 'sourcemap'],
},
webpack: {
context: webpackConfig.context,
devtool: 'inline-source-map',
resolve: {
alias: {
'app-config': toPath('test/app.config.test.json'),
},
},
module: {
loaders: [{
test: /\.svg$/,
loaders: [
'file?name=[path][name].[ext]',
'svgo',
],
}, {
test: /\.(png|jpg|jpeg|gif|woff|woff2|ttf|eot|otf|webm|mp4|ogg|wav)$/,
loader: 'file?name=[path][name].[ext]',
}, {
test: /\.js$/,
exclude: /(node_modules|vendor\.js)/,
loader: 'babel?' + JSON.stringify(babelSettings),
}, {
test: /\.json$/,
loader: 'json',
}, {
test: /\.(s?[ac]ss|html?|md)$/,
include: [
path.resolve(__dirname, 'src/'),
path.resolve(__dirname, 'src/app/pages'),
path.resolve(__dirname, 'src/app/shared'),
],
loader: 'null',
}],
},
plugins: [
new DefinePlugin({
'process.env': JSON.stringify({NODE_ENV: 'testing'}),
'__BUILD_STATS__': JSON.stringify({
gitCommit: {
hash: 'githash',
branch: 'gitbranch',
},
host: 'buildhost',
time: +(new Date()),
}),
}),
],
},
webpackMiddleware: {
noInfo: true,
},
});
};