Skip to content

Commit d445007

Browse files
devversionkara
authored andcommitted
build: simplify karma configuration (#2823)
1 parent 4a4261e commit d445007

File tree

5 files changed

+419
-500
lines changed

5 files changed

+419
-500
lines changed

test/browser-providers.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
'use strict';
2+
3+
/*
4+
* Browser Configuration for the different jobs in the CI.
5+
* Target can be either: BS (Browserstack) | SL (Saucelabs) | null (To not run at all)
6+
*/
7+
const browserConfig = {
8+
'Chrome': { unitTest: {target: 'SL', required: true }},
9+
'Firefox': { unitTest: {target: 'SL', required: true }},
10+
'ChromeBeta': { unitTest: {target: 'SL', required: false }},
11+
'FirefoxBeta': { unitTest: {target: null, required: false }},
12+
'ChromeDev': { unitTest: {target: null, required: true }},
13+
'FirefoxDev': { unitTest: {target: null, required: true }},
14+
'IE9': { unitTest: {target: null, required: false }},
15+
'IE10': { unitTest: {target: null, required: true }},
16+
'IE11': { unitTest: {target: 'SL', required: true }},
17+
'Edge': { unitTest: {target: 'SL', required: true }},
18+
'Android4.1': { unitTest: {target: null, required: false }},
19+
'Android4.2': { unitTest: {target: null, required: false }},
20+
'Android4.3': { unitTest: {target: null, required: false }},
21+
'Android4.4': { unitTest: {target: 'SL', required: false }},
22+
'Android5': { unitTest: {target: 'SL', required: false }},
23+
'Safari7': { unitTest: {target: null, required: false }},
24+
'Safari8': { unitTest: {target: 'BS', required: false }},
25+
'Safari9': { unitTest: {target: 'BS', required: false }},
26+
'iOS7': { unitTest: {target: null, required: false }},
27+
'iOS8': { unitTest: {target: null, required: false }},
28+
'iOS9': { unitTest: {target: 'BS', required: true }},
29+
'WindowsPhone': { unitTest: {target: 'BS', required: false }}
30+
};
31+
32+
/** Exports all available remote browsers. */
33+
exports.customLaunchers = require('./remote_browsers.json');
34+
35+
/** Exports a map of configured browsers, which should run on the CI. */
36+
exports.platformMap = {
37+
'saucelabs': {
38+
required: buildConfiguration('unitTest', 'SL', true),
39+
optional: buildConfiguration('unitTest', 'SL', false)
40+
},
41+
'browserstack': {
42+
required: buildConfiguration('unitTest', 'BS', true),
43+
optional: buildConfiguration('unitTest', 'BS', false)
44+
},
45+
};
46+
47+
/** Build a list of configuration (custom launcher names). */
48+
function buildConfiguration(type, target, required) {
49+
return Object.keys(browserConfig)
50+
.map(item => [item, browserConfig[item][type]])
51+
.filter(([, conf]) => conf.required === required && conf.target === target)
52+
.map(([item]) => `${target}_${item.toUpperCase()}`);
53+
}
54+
55+
/** Decode the token for Travis to use. */
56+
function decodeToken(token) {
57+
return (token || '').split('').reverse().join('');
58+
}
59+
60+
61+
/** Ensures that the Travis access keys work properly. */
62+
if (process.env.TRAVIS) {
63+
process.env.SAUCE_ACCESS_KEY = decodeToken(process.env.SAUCE_ACCESS_KEY);
64+
process.env.BROWSER_STACK_ACCESS_KEY = decodeToken(process.env.BROWSER_STACK_ACCESS_KEY);
65+
}

0 commit comments

Comments
 (0)