-
Notifications
You must be signed in to change notification settings - Fork 1
/
karma.conf.js
108 lines (102 loc) · 3.52 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
const path = require('path');
const webpackConfig = require('./webpack.config.common');
const isProductionBuild = process.env.NODE_ENV === 'production';
const shouldWatch = !isProductionBuild;
const shouldSingleRun = isProductionBuild;
process.env.CHROME_BIN = require('puppeteer').executablePath();
webpackConfig.devtool = 'inline-source-map';
webpackConfig.mode = 'development';
webpackConfig.module.rules.push({
test: /\.js$/,
enforce: 'post',
exclude: [/\.spec.js$/, /node_modules/, /karma-test-shim.js$/],
loader: 'istanbul-instrumenter-loader',
query: {
esModules: true
}
});
module.exports = function (config) {
const logLevel = isProductionBuild ? config.LOG_DEBUG : config.LOG_INFO;
config.set({
basePath: '',
files: [
{ pattern: './karma-test-shim.js', watched: false }
// uncomment these two for Firefox, Edge support
// { pattern: './node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js', watched: false },
// { pattern: './node_modules/@webcomponents/webcomponentsjs/webcomponents-bundle.js', watched: false }
],
preprocessors: {
'./karma-test-shim.js': ['webpack', 'sourcemap']
},
frameworks: ['jasmine'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-firefox-launcher'),
require('karma-junit-reporter'),
require('karma-coverage-istanbul-reporter'),
require('karma-webpack'),
require('karma-sourcemap-loader')
],
webpack: webpackConfig,
reporters: ['progress', 'dots', 'junit', 'coverage-istanbul'],
port: 9876,
colors: true,
logLevel: logLevel,
autoWatch: shouldWatch,
// currently supported by CEA out of the box: Chrome (headless) and Firefox
// to add more browsers: http://karma-runner.github.io/3.0/config/browsers.html
browsers: ['ChromiumHeadlessConfigured'],
customLaunchers: {
ChromiumHeadlessConfigured: {
base: 'ChromeHeadless',
flags: [
'--no-sandbox',
'--disable-setuid-sandbox'
] // https://github.com/Googlechrome/puppeteer/issues/290#issuecomment-322852784
}
},
singleRun: shouldSingleRun,
captureTimeout: 210000, // https://github.com/jasmine/jasmine/issues/1413#issuecomment-334247097
browserDisconnectTolerance: 3,
browserDisconnectTimeout: 210000,
browserNoActivityTimeout: 210000,
concurrency: Infinity,
junitReporter: {
outputDir: './reports/test-results/',
outputFile: 'test-results.xml',
suite: 'create-evergreen-app',
useBrowserName: false
},
coverageIstanbulReporter: {
'dir': path.join(__dirname, 'reports'),
'reports': ['html', 'cobertura', 'text-summary'],
'report-config': {
'html': {
subdir: 'test-coverage'
},
'cobertura': {
file: 'test-coverage/coverage.xml'
},
'text-summary': {}
},
'fixWebpackSourcePaths': true,
'remapOptions': {
exclude: [/\*.spec.ts/]
},
// anything under these percentages will cause karma to fail with an exit code of 1 if not running in watch mode
// currently not working: https://github.com/mattlewis92/karma-coverage-istanbul-reporter/issues/49
'thresholds': {
// set to `true` to not fail the test command when thresholds are not met
emitWarning: false,
// thresholds for all files
global: {
statements: 90,
branches: 75,
functions: 90,
lines: 90
}
}
}
});
};