forked from okta/okta-signin-widget
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
80 lines (76 loc) · 2.38 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
/* global __dirname, module */
const path = require('path');
const webpackConfig = require('./webpack.test.config.js');
const karmaOverrides = require('./test/unit/karma/karma-overrides');
const rootDir = path.resolve(__dirname);
module.exports = (config) => {
const options = {
basePath: './',
browsers: ['ChromeHeadlessNoSandbox'],
frameworks: ['karma-overrides', 'jasmine-jquery', 'jasmine'],
files: [
{ pattern: './test/unit/main.js', watched: false },
{ pattern: './test/unit/assets/*', watched: false, included: false, served: true, nocache: false },
{ pattern: './target/css/*.css', watched: true, included: true, served: true },
{ pattern: './target/**/*', watched: false, included: false, served: true },
],
proxies: {
'/img/logos/': 'http://localhost:9876/base/test/unit/assets/'
},
preprocessors: {
'test/unit/main.js': ['webpack', 'sourcemap'],
},
plugins: [
'karma-*',
karmaOverrides,
],
reporters: ['junit', 'mocha'],
junitReporter: {
outputDir: `${rootDir}/build2/reports/unit`,
outputFile: 'okta-sign-in-widget-junit-result.xml',
useBrowserName: false,
},
coverageReporter: {
reporters: [
{ type: 'text' },
{ type: 'html', dir: `${rootDir}/build2/reports/coverage` }
],
},
webpack: webpackConfig,
webpackMiddleware: {
stats: 'normal',
},
client: {
// Passing specific test to run
// but this works only with `karma start`, not `karma run`.
test: config.test,
jasmine: {
timeoutInterval: 10000, // increased timeout for Travis
random: false
}
},
failOnEmptyTestSuite: false,
customLaunchers: {
FirefoxHeadless: {
base: 'Firefox',
flags: [ '-headless' ],
},
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
customHeaders: [{
match: '.*.html',
name: 'Content-Security-Policy',
value: 'script-src http: \'unsafe-inline\''
}]
};
// instrument code for coverage report
if (config.reporters.includes('coverage')) {
const rules = options.webpack.module.rules;
const babelRule = rules.find(rule => rule.loader === 'babel-loader');
babelRule.options.plugins = babelRule.options.plugins.concat(['babel-plugin-istanbul']);
}
config.set(options);
};