This repository was archived by the owner on Dec 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathshared.karma.conf.js
112 lines (98 loc) · 2.86 KB
/
shared.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
109
110
111
112
/*jslint node: true */
'use strict';
const logger = require('@blackbaud/skyux-logger');
/**
* Adds the necessary configuration for code coverage thresholds.
* @param {*} config
*/
function getCoverageThreshold(skyPagesConfig) {
function getProperty(threshold) {
return {
global: {
statements: threshold,
branches: threshold,
functions: threshold,
lines: threshold
}
};
}
switch (skyPagesConfig.skyux.codeCoverageThreshold) {
case 'none':
return getProperty(0);
case 'standard':
return getProperty(80);
case 'strict':
return getProperty(100);
}
}
/**
* Common Karma configuration shared between local / CI testing.
* @name getConfig
*/
function getConfig(config) {
// This file is spawned so we'll need to read the args again
const minimist = require('minimist');
const argv = minimist(process.argv.slice(2));
const path = require('path');
let testWebpackConfig = require('../webpack/test.webpack.config');
let remapIstanbul = require('remap-istanbul');
// See minimist documentation regarding `argv._` https://github.com/substack/minimist
let skyPagesConfig = require('../sky-pages/sky-pages.config').getSkyPagesConfig(argv._[0]);
// Using __dirname so this file can be extended from other configuration file locations
const specBundle = `${__dirname}/../../utils/spec-bundle.js`;
const specStyles = `${__dirname}/../../utils/spec-styles.js`;
let preprocessors = {};
preprocessors[specBundle] = ['coverage', 'webpack', 'sourcemap'];
preprocessors[specStyles] = ['webpack'];
config.set({
basePath: '',
frameworks: ['jasmine'],
exclude: [],
files: [
{
pattern: specBundle,
watched: false
},
{
pattern: specStyles,
watched: false
}
],
preprocessors: preprocessors,
skyPagesConfig: skyPagesConfig,
webpack: testWebpackConfig.getWebpackConfig(skyPagesConfig, argv),
coverageReporter: {
dir: path.join(process.cwd(), 'coverage'),
check: getCoverageThreshold(skyPagesConfig),
reporters: [
{ type: 'json' },
{ type: 'html' },
{ type: 'text-summary' },
{ type: 'lcov' }
],
_onWriteReport: function (collector) {
return remapIstanbul.remap(collector.getFinalCoverage());
}
},
webpackServer: {
noInfo: true,
stats: 'minimal'
},
// This flag allows console.log calls to come through the cli
browserConsoleLogOptions: {
level: 'log'
},
reporters: ['mocha', 'coverage'],
port: 9876,
colors: logger.logColor,
logLevel: config.LOG_INFO,
browserDisconnectTimeout: 3e5,
browserDisconnectTolerance: 3,
browserNoActivityTimeout: 3e5,
captureTimeout: 3e5,
autoWatch: false,
singleRun: true,
failOnEmptyTestSuite: false
});
}
module.exports = getConfig;