-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.test.config.js
77 lines (66 loc) · 2.74 KB
/
webpack.test.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
var webpack = require("webpack");
var I18nPlugin = require("./frontend_build/i18nPlugin");
var ClientAppsPlugin = require("./frontend_build/clientAppPlugin");
var CompiledReferencePlugin = require("./frontend_build/CompiledReferencePlugin");
var baseWebpackConfig = require("./frontend_build/baseWebpackConfig");
var testWebpackConfig = baseWebpackConfig;
var jspecEnv = require('./spec/jspec_env');
// the ember specs don't play nice with the rest,
// so we run them in totally seperate bundles
if (process.env.WEBPACK_TEST_BUNDLE == 'ember') {
testWebpackConfig.entry = {
'WebpackedEmberSpecs': "./spec/javascripts/webpack_ember_spec_index.js"
}
} else {
testWebpackConfig.entry = {
'WebpackedSpecs': "./spec/javascripts/webpack_spec_index.js"
}
}
testWebpackConfig.devtool = undefined;
testWebpackConfig.output.path = __dirname + '/spec/javascripts/webpack';
testWebpackConfig.output.pathinfo = true;
testWebpackConfig.output.filename = "[name].bundle.test.js";
testWebpackConfig.plugins = [
// expose a 'qunit' global variable to any file that uses it
new webpack.ProvidePlugin({qunit: 'qunitjs'}),
new I18nPlugin(),
new ClientAppsPlugin(),
new CompiledReferencePlugin(),
new webpack.IgnorePlugin(/\.md$/),
new webpack.IgnorePlugin(/(CHANGELOG|LICENSE|README)$/),
new webpack.IgnorePlugin(/package.json/),
new webpack.DefinePlugin(jspecEnv),
];
testWebpackConfig.resolve.alias.qunit = 'qunitjs';
testWebpackConfig.resolve.root.push(__dirname + '/spec/coffeescripts');
testWebpackConfig.resolve.root.push(__dirname + '/spec/javascripts/support');
testWebpackConfig.resolve.alias["spec/jsx"] = __dirname + '/spec/javascripts/jsx';
// Some plugins use a special spec_canvas path for their specs
testWebpackConfig.module.loaders.unshift({
test: [
/\/spec\/coffeescripts\//,
/\/spec_canvas\/coffeescripts\//,
/\/spec\/javascripts\/jsx\//,
/\/ember\/.*\/tests\//
],
// Our spec files expect qunit's global `test`, `module`, `asyncTest` and `start` variables.
// These imports loaders make it so they are avalable as local variables
// inside of a closure, without truly making them globals.
// We should get rid of this and just change our actual source to s/test/qunit.test/ and s/module/qunit.module/
loaders: [
'imports?test=>qunit.test',
'imports?asyncTest=>qunit.asyncTest',
'imports?start=>qunit.start',
"qunitDependencyLoader"
]
});
testWebpackConfig.module.postLoaders = [{
test: /(jsx.*(\.js$|\.jsx$)|\.coffee$|public\/javascripts\/.*\.js$)/,
exclude: /(node_modules|spec|public\/javascripts\/(bower|client_apps|compiled|jst|jsx|translations|vendor))/,
loader: 'istanbul-instrumenter'
}]
testWebpackConfig.module.noParse = [
/\/sinon-1.17.2.js/,
/\/axe.js/
]
module.exports = testWebpackConfig;