forked from webex/webex-js-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma-ng.conf.js
176 lines (138 loc) · 4.36 KB
/
karma-ng.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/* eslint-disable func-names */
/* eslint-disable global-require */
/* eslint-disable require-jsdoc */
/* eslint-disable import/no-dynamic-require */
// eslint-disable-next-line strict
const path = require('path');
const {flatten} = require('lodash');
const makeBrowsers = require('./browsers-ng');
/* eslint-disable global-require */
module.exports = function configureKarma(config) {
config.set(makeConfig(process.env.PACKAGE));
};
module.exports.makeConfig = makeConfig;
function makeConfig(packageName, argv) {
// In case incoming argument is ['Chrome', 'Firefox', 'Safari,ie']
// Cleanup and return ['Chrome', 'Firefox' 'Safari', 'ie']
argv.browsers =
argv.browsers &&
flatten(
argv.browsers.map((browser) =>
browser.includes(',') ? browser.toLowerCase().split(',') : browser.toLowerCase()
)
);
argv.os =
argv.os &&
flatten(
argv.os.map((os) => (os.includes(',') ? os.toLowerCase().split(',') : os.toLowerCase()))
);
/* eslint complexity: [0] */
const launchers = makeBrowsers(packageName, argv);
const integrationTestPath = path.join(
'packages',
packageName,
'test',
'integration',
'spec',
'**',
'*.js'
);
const unitTestPath = path.join('packages', packageName, 'test', 'unit', 'spec', '**', '*.js');
const preprocessors = {
'packages/**': ['browserify'],
// 'packages/**/*.ts': ['tsify', 'browserify']
};
const files = ['node_modules/@babel/polyfill/dist/polyfill.js'];
if (!argv || argv.unit) {
files.push(unitTestPath);
}
if (!argv || argv.integration) {
files.push(integrationTestPath);
}
let cfg = {
basePath: '.',
browserDisconnectTimeout: 5 * 60 * 1000,
// Allow the browser to disconnect up to 5 times. Something about
// plugin-meetings and Firefox causes the suite to hang regularly. Restarting
// the browser seems to fix it, so we need to allow a largish number of
// restarts.
browserDisconnectTolerance: 3,
browsers: Object.keys(launchers),
browserify: {
debug: true,
watch: argv && argv.karmaDebug,
extensions: ['.ts', '.js'],
transform: [
[
'babelify',
{
extensions: ['.ts', '.js'],
global: true,
ignore: ['node_modules'],
},
],
'envify',
],
},
// Restart the browser if it stops sending output for a minutes. This goes
// hand-in-hand with the high disconnect tolerance to deal with Firefox
// hanging on the plugin-meetings suite.
browserNoActivityTimeout: 8 * 60 * 1000,
// Inspired by Angular's karma config as recommended by Sauce Labs
captureTimeout: 0,
colors: true,
concurrency: 4,
customLaunchers: launchers,
failOnEmptyTestSuite: false, // allow empty or skipped specs (like calendar) to not make karma fail
files,
frameworks: ['browserify', 'mocha', 'chai'],
hostname: 'localhost',
logLevel: process.env.KARMA_LOG_LEVEL || 'INFO', // INFO is default value
browserConsoleLogOptions: {
level: 'warn',
},
client: {
captureConsole: true,
mocha: {
bail: argv.bail,
// TODO figure out how to report retries
retries: process.env.JENKINS || process.env.CI ? 1 : 0,
timeout: 30000,
grep: argv && argv.grep[0],
},
},
mochaReporter: {
// Hide the skipped tests on jenkins to more easily see which tests failed
ignoreSkipped: true,
},
port: parseInt(process.env.KARMA_PORT, 10) || 9001,
preprocessors,
proxies: {
'/fixtures/': `http://localhost:${process.env.FIXTURE_PORT}/`,
'/upload': `http://localhost:${process.env.FIXTURE_PORT}/upload`,
},
reporters: ['mocha'],
singleRun: !(argv && argv.karmaDebug),
// video and screenshots add on the request of sauce labs support to help
// diagnose test user creation timeouts
recordVideo: true,
recordScreenshots: true,
};
if (process.env.COVERAGE || process.env.CI) {
cfg.junitReporter = {
outputFile: `${packageName}.xml`,
outputDir: 'reports/junit/karma',
suite: packageName,
useBrowserName: true,
recordScreenshots: true,
recordVideo: true,
};
cfg.reporters.push('junit');
}
try {
cfg = require(`./packages/${packageName}/karma.conf.js`)(cfg);
} catch (error) {
// ignore
}
return cfg;
}