|
5 | 5 | * Target can be either: BS (Browserstack) | SL (Saucelabs) | TC (Travis CI) | null (To not run) |
6 | 6 | */ |
7 | 7 | const browserConfig = { |
8 | | - 'ChromeHeadlessCI': { unitTest: {target: 'TC', required: true }}, |
9 | | - 'FirefoxHeadless': { unitTest: {target: 'TC', required: true }}, |
10 | | - 'ChromeBeta': { unitTest: {target: null, 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: null, required: false }}, |
22 | | - 'Android5': { unitTest: {target: null, required: false }}, |
23 | | - 'Safari7': { unitTest: {target: null, required: false }}, |
24 | | - 'Safari8': { unitTest: {target: null, required: false }}, |
25 | | - 'Safari9': { unitTest: {target: 'SL', required: true }}, |
26 | | - 'Safari10': { unitTest: {target: 'BS', required: true }}, |
27 | | - 'iOS7': { unitTest: {target: null, required: false }}, |
28 | | - 'iOS8': { unitTest: {target: null, required: false }}, |
29 | | - 'iOS9': { unitTest: {target: null, required: false }}, |
30 | | - 'iOS10': { unitTest: {target: 'BS', required: true }}, |
31 | | - 'WindowsPhone': { unitTest: {target: null, required: false }} |
| 8 | + 'ChromeHeadlessCI': { target: 'TC', poolId: 1 }, |
| 9 | + 'FirefoxHeadless': { target: 'TC', poolId: 1 }, |
| 10 | + 'ChromeBeta': { target: null }, |
| 11 | + 'FirefoxBeta': { target: null }, |
| 12 | + 'ChromeDev': { target: null }, |
| 13 | + 'FirefoxDev': { target: null }, |
| 14 | + 'IE9': { target: null }, |
| 15 | + 'IE10': { target: null }, |
| 16 | + 'IE11': { target: 'BS', poolId: 2 }, |
| 17 | + 'Edge': { target: 'BS', poolId: 2 }, |
| 18 | + 'Android4.1': { target: null }, |
| 19 | + 'Android4.2': { target: null }, |
| 20 | + 'Android4.3': { target: null }, |
| 21 | + 'Android4.4': { target: null }, |
| 22 | + 'Android5': { target: null }, |
| 23 | + 'Safari7': { target: null }, |
| 24 | + 'Safari8': { target: null }, |
| 25 | + 'Safari9': { target: 'BS', poolId: 1 }, |
| 26 | + 'Safari10': { target: 'BS', poolId: 1 }, |
| 27 | + 'iOS7': { target: null }, |
| 28 | + 'iOS8': { target: null }, |
| 29 | + 'iOS9': { target: null }, |
| 30 | + 'iOS10': { target: 'BS', poolId: 1 }, |
| 31 | + 'WindowsPhone': { target: null } |
32 | 32 | }; |
33 | 33 |
|
34 | 34 | /** Exports all available remote browsers. */ |
35 | 35 | exports.customLaunchers = require('./remote_browsers.json'); |
36 | 36 |
|
37 | 37 | /** Exports a map of configured browsers, which should run on the CI. */ |
38 | 38 | exports.platformMap = { |
39 | | - 'saucelabs': { |
40 | | - required: buildConfiguration('unitTest', 'SL', true), |
41 | | - optional: buildConfiguration('unitTest', 'SL', false) |
42 | | - }, |
43 | | - 'browserstack': { |
44 | | - required: buildConfiguration('unitTest', 'BS', true), |
45 | | - optional: buildConfiguration('unitTest', 'BS', false) |
46 | | - }, |
47 | | - 'travis': { |
48 | | - required: buildConfiguration('unitTest', 'TC', true), |
49 | | - optional: buildConfiguration('unitTest', 'TC', false) |
50 | | - } |
| 39 | + 'browserstack': buildConfiguration('BS'), |
| 40 | + 'travis': buildConfiguration('TC'), |
51 | 41 | }; |
52 | 42 |
|
53 | | -/** Build a list of configuration (custom launcher names). */ |
54 | | -function buildConfiguration(type, target, required) { |
55 | | - const targetBrowsers = Object.keys(browserConfig) |
56 | | - .map(browserName => [browserName, browserConfig[browserName][type]]) |
57 | | - .filter(([, config]) => config.required === required && config.target === target) |
58 | | - .map(([browserName]) => browserName); |
| 43 | +/** Ensures that the Travis access keys work properly. */ |
| 44 | +if (process.env.TRAVIS) { |
| 45 | + process.env.BROWSER_STACK_ACCESS_KEY = decodeToken(process.env.BROWSER_STACK_ACCESS_KEY); |
| 46 | +} |
| 47 | + |
| 48 | +/** Build a list of configuration for the specified platform. */ |
| 49 | +function buildConfiguration(platform) { |
| 50 | + const platformConfig = {}; |
| 51 | + |
| 52 | + Object.keys(browserConfig).forEach(browserName => { |
| 53 | + const config = browserConfig[browserName]; |
| 54 | + |
| 55 | + if (config.target !== platform && !config.poolId) { |
| 56 | + return; |
| 57 | + } |
| 58 | + |
| 59 | + if (!platformConfig[config.poolId]) { |
| 60 | + platformConfig[config.poolId] = []; |
| 61 | + } |
59 | 62 |
|
60 | | - // For browsers that run on Travis CI the browser name shouldn't be prefixed with the shortcut |
61 | | - // of Travis. The different Karma launchers only work with the plain browser name (e.g Firefox) |
62 | | - if (target === 'TC') { |
63 | | - return targetBrowsers; |
64 | | - } |
| 63 | + // For browsers that run on Travis CI the browser name shouldn't be prefixed with the shortcut |
| 64 | + // of Travis. The different Karma launchers only work with the plain browser name (e.g Firefox) |
| 65 | + if (platform !== 'TC') { |
| 66 | + browserName = `${platform}_${browserName.toUpperCase()}`; |
| 67 | + } |
65 | 68 |
|
66 | | - return targetBrowsers.map(browserName => `${target}_${browserName.toUpperCase()}`); |
| 69 | + platformConfig[config.poolId].push(browserName); |
| 70 | + }); |
| 71 | + |
| 72 | + return platformConfig; |
67 | 73 | } |
68 | 74 |
|
69 | 75 | /** Decode the token for Travis to use. */ |
70 | 76 | function decodeToken(token) { |
71 | 77 | return (token || '').split('').reverse().join(''); |
72 | 78 | } |
73 | | - |
74 | | - |
75 | | -/** Ensures that the Travis access keys work properly. */ |
76 | | -if (process.env.TRAVIS) { |
77 | | - process.env.SAUCE_ACCESS_KEY = decodeToken(process.env.SAUCE_ACCESS_KEY); |
78 | | - process.env.BROWSER_STACK_ACCESS_KEY = decodeToken(process.env.BROWSER_STACK_ACCESS_KEY); |
79 | | -} |
0 commit comments