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