forked from folio-org/ui-eholdings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
79 lines (64 loc) · 2.14 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
const path = require('path');
const webpack = require('webpack');
// Start with the base stripes webpack config.
// we'll need to make some changes in order to get
// karma-webpack to load properly.
const webpackConfig = require('@folio/stripes-core/webpack.config.cli.dev');
// This is not a separate platform, so we need to stub out our own
// stripes config. Whenever code in the application, or in stripes
// itself does `import 'stripes-loader'`, it will find our test
// config.
//
// Note that stripes has its own rules for handling the
// `stripes-loader` package, so we have to remove its custom rule above.
webpackConfig.resolve.alias['stripes-loader'] = path.resolve(__dirname, 'tests/stripes.config.js');
// The webpack config provided by stripes-core, contains the `stripes-loader` module which uses
// itself as a loader. We turn this off by finding the rule and
// removing it from the webpack config, so that our own shim for the
// `stripes-loader` module does not get overriden.
// see `@folio/stripes-loader`
// see `@folio/stripes-core/webpack.config.base.js`
webpackConfig.module.rules = webpackConfig.module.rules.filter(rule => {
return !rule.use || !rule.use.some(use => use.loader === '@folio/stripes-loader');
});
// make sure that the NODE_ENV is available in browser code.
webpackConfig.plugins.push(new webpack.EnvironmentPlugin({
NODE_ENV: 'test'
}));
module.exports = function(config) {
let configuration = {
frameworks: ['mocha'],
reporters: ['mocha'],
port: 9876,
browsers: ['Chrome'],
customLaunchers: {
Chrome_travis_ci: {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
files: [
{ pattern: 'tests/index.js', watched: false }
],
preprocessors: {
'tests/index.js': ['webpack']
},
webpack: webpackConfig,
webpackMiddleware: {
stats: "errors-only"
},
mochaReporter: {
showDiff: true
},
plugins: [
'karma-chrome-launcher',
'karma-mocha',
'karma-webpack',
'karma-mocha-reporter'
]
};
if (process.env.TRAVIS) {
configuration.browsers = ['Chrome_travis_ci'];
}
config.set(configuration);
};