This repository has been archived by the owner on Jul 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
140 lines (112 loc) · 4.2 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Karma configuration
// Generated on Sat Nov 19 2016 00:50:37 GMT+0100 (CET)
/* eslint-env node */
const path = require('path');
const argv = require('minimist')(process.argv.slice(2));
const UNIT_TESTS = 'src/test/*spec.js';
// const SOURCE_FILES = 'src/lib/*.js';
let files = [];
let preprocessors = {};
if (argv.examples) {
// export library for examples
let webpack = require('webpack');
let webpackConfig = require('./webpack.config.js')({});
// returns a Compiler instance
let compiler = webpack(webpackConfig);
compiler.watch({ // watch options:
aggregateTimeout: 300, // wait so long for more changes
poll: true // use polling instead of native watchers
}, (err, stats) => {
if (err) {
throw err;
}
if (stats.hasErrors()) {
console.log('webpack threw errors compiling!');
console.log(stats.toJson('errors-only'));
}
});
files.push(
{pattern: 'examples/**/*', watched: true, included: false},
{pattern: 'dist/*', watched: true, included: false, nocache: true}
);
} else if (argv.test) {
files.push(UNIT_TESTS);
preprocessors[UNIT_TESTS] = ['webpack'];
/**
* instambul is not working properly since change to es6 modules
* @see https://github.com/karma-runner/karma-coverage/issues/157
*/
// preprocessors[SOURCE_FILES] = ['coverage'];
} else {
console.log('please use --examples or --test option!');
process.exit(1);
}
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
proxies: {
'/example/': '/base/examples/',
'/dist/': '/base/dist/'
},
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'chai'],
// list of files / patterns to load in the browser
files: files,
// list of files to exclude
exclude: [],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: preprocessors,
webpack: {
module: {
rules: [
// instrument only testing sources with Istanbul
// {
// test: /\.js$/,
// include: path.resolve('src/lib/'),
// loader: 'istanbul-instrumenter'
// },
{
test: /\.js$/,
enforce: 'pre',
use: ['babel-loader'],
include: [
path.resolve('src/lib/'),
path.resolve('src/test/'),
path.resolve('src/index.js')
]
},
{
test:/.css$/,
enforce: 'pre',
use: ['css-loader']
}
]
}
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'coverage'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: [],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
});
};