-
Notifications
You must be signed in to change notification settings - Fork 37
/
karma.conf.js
executable file
·62 lines (58 loc) · 2.02 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
const webpack = require('webpack');
const webpackConfig = require('./webpack.config.js');
process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function (config) {
const mode = 'development';
const { filename: _f, ...strippedOutput } = webpackConfig.output;
const { entry: _e, output, ...strippedConfig } = webpackConfig;
strippedConfig.output = strippedOutput;
config.set({
autoWatch: true,
browsers: ['ChromeHeadless_without_sandbox'],
frameworks: ['jasmine', 'webpack'],
customLaunchers: {
ChromeHeadless_without_sandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox'],
},
},
files: ['./spec/entry.js'],
preprocessors: {
'./spec/entry.js': ['webpack'],
},
webpack: {
...strippedConfig,
mode,
plugins: [
...strippedConfig.plugins,
new webpack.ProvidePlugin({
// Make a global `process` variable that points to the `process` package,
// because the `util` package expects there to be a global variable named `process`.
// Thanks to https://stackoverflow.com/a/65018686/14239942
process: 'process/browser.js',
}),
],
resolve: {
...strippedConfig.resolve,
fallback: {
...strippedConfig.resolve.fallback,
// Various packages inside of karma and around testing utilize node
// features, but webpack 5 does not bundle polyfills by default
// anymore, so we have to vendor them ourselves.
buffer: require.resolve('buffer'),
events: require.resolve('events'),
util: require.resolve('util'),
stream: require.resolve('stream-browserify'),
string_decoder: require.resolve('string_decoder'),
},
},
},
webpackMiddleware: {
// webpack-dev-middleware configuration
// i. e.
noInfo: true,
poll: 1000,
},
plugins: [require('karma-chrome-launcher'), require('karma-jasmine'), require('karma-webpack')],
});
};