-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
karma.sauce.js
161 lines (123 loc) · 5.04 KB
/
karma.sauce.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
var fs = require('fs');
// karma start karma.sauce
module.exports = function(config) {
// Use ENV vars on Travis and sauce.json locally to get credentials
if (process.env.SAUCE_USERNAME) {
console.log('使用全局的sauce key')
} else {
if (!fs.existsSync('sauce.json')) {
console.log('Create a sauce.json with your credentials based on the sauce-sample.json file.');
process.exit(1);
} else {
console.log('使用sauce.json!')
process.env.SAUCE_USERNAME = require('./sauce').username;
process.env.SAUCE_ACCESS_KEY = require('./sauce').accessKey;
}
}
// https://saucelabs.com/platforms
// Browsers to run on Sauce Labs
function createCustomLauncher(browser, platform, version) {
if (browser === 'IE') {
browser = 'internet explorer'
}
if (browser === 'iphone') {
if (platform === null) {
platform = '1.5.3'
}
return {
base: "SauceLabs",
browserName: "iphone",
platform: platform,
version: version,
"device-orientation": "portrait"
}
}
return {
base: 'SauceLabs',
browserName: browser,
platform: platform,
version: version
};
}
var customLaunchers = {
sl_win_ie_10: createCustomLauncher('IE', 'Windows 8', '10'),
sl_win_ie_8: createCustomLauncher('IE', 'Windows XP', '8'),
sl_win_ie_9: createCustomLauncher('IE', 'Windows 2008', '9'),
sl_win_ie_11: createCustomLauncher('IE', 'Windows 8.1', '11'),
sl_edge_13: createCustomLauncher('MicrosoftEdge', 'Windows 10', '13'),
chrome55: createCustomLauncher('chrome', 'OS X 10.10', '55.0'),
chrome45: createCustomLauncher('chrome', 'OS X 10.8', '45.0'),
chrome30: createCustomLauncher('chrome', 'Windows 7', '30.0'),
sl_edge_14: createCustomLauncher('MicrosoftEdge', 'Windows 10', '14'),
sl_win_ie_7: createCustomLauncher('IE', 'Windows XP', '7'),
firefox20: createCustomLauncher('firefox', 'Windows XP', '20.0'),
firefox40: createCustomLauncher('firefox', 'Windows 8', '40.0'),
firefox50: createCustomLauncher('firefox', 'OS X 10.9', '50.0'),
//chrome最低只支持到26
// Safari (last 2 versions)
sl_safari9: createCustomLauncher('safari', 'OS X 10.11', '9'),
sl_safari8: createCustomLauncher('safari', 'OS X 10.10', '8'),
sl_safari7: createCustomLauncher('safari', 'OS X 10.9', '7'),
sl_android_4_0: createCustomLauncher('android', null, '4.0'),
sl_android_4_4: createCustomLauncher('android', null, '4.4'),
sl_android_5_1: createCustomLauncher('android', null, '5.1'),
// iOS (last 2 major versions)
sl_ios9_iphone: {
base: 'SauceLabs',
browserName: 'iphone',
platform: 'OS X 10.10',
version: '9.2',
},
sl_ios8_iphone: {
base: 'SauceLabs',
browserName: 'iphone',
platform: 'OS X 10.10',
version: '8.4',
},
};
//https://github.com/karma-runner/karma-sauce-launcher/issues/61
// https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'./test/promise.js',
'./test/matchers.js',
'./test/beforeIt.js',
'./test/jquery.js',
'./dist/avalon.sauce.js'
],
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['dots', 'saucelabs'],
// web server port
port: 9876,
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
retryLimit: 10, //为了保证都能运行这么多浏览器,必须添加重起的次数
sauceLabs: {
testName: '加大mac测试',
//recordScreenshots: false,
connectOptions: {
port: 5757,
logfile: 'sauce_connect.log'
},
public: 'public'
},
captureTimeout: 160000,
customLaunchers: customLaunchers,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: Object.keys(customLaunchers),
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true
});
};