-
Notifications
You must be signed in to change notification settings - Fork 18
/
karma.runner.js
49 lines (40 loc) · 1.09 KB
/
karma.runner.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
var Config = require('karma/lib/config').Config;
var Server = require('karma').Server;
var ModernizrWebpackPlugin = require('./index');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var createConfig = require('./karma.conf');
var karmaConfig = createConfig(new Config());
var path = require('path');
var del = require('del');
var OUTPUT_PATH = path.resolve(__dirname, 'temp');
del(OUTPUT_PATH);
var webpack = require('webpack');
var webpackConfig = {
context: __dirname,
entry: {
'entry-bundle': './tests/entry.js'
},
output: {
filename: '[name].js',
path: OUTPUT_PATH
},
plugins: [
new HtmlWebpackPlugin(),
new ModernizrWebpackPlugin({
'feature-detects': require('./tests/feature-detects')
})
]
};
function executeTestingServer(source) {
var config = Object.assign({}, karmaConfig);
config.files.push(source);
var server = new Server(config);
server.start();
}
webpack(webpackConfig, function (err) {
if (err) {
console.error(err);
process.exit(0);
}
executeTestingServer(path.resolve(OUTPUT_PATH, 'modernizr-bundle.js'));
});