forked from axios/axios
-
Notifications
You must be signed in to change notification settings - Fork 3
/
karma.conf.js
246 lines (197 loc) · 6.75 KB
/
karma.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
// Karma configuration
// Generated on Fri Aug 15 2014 23:11:13 GMT-0500 (CDT)
var webpack = require('webpack');
function createCustomLauncher(browser, version, platform) {
return {
base: 'SauceLabs',
browserName: browser,
version: version,
platform: platform
};
}
module.exports = function(config) {
var customLaunchers = {};
var browsers = [];
if (process.env.SAUCE_USERNAME || process.env.SAUCE_ACCESS_KEY) {
customLaunchers = {};
var runAll = true;
var options = [
'SAUCE_CHROME',
'SAUCE_FIREFOX',
'SAUCE_SAFARI',
'SAUCE_OPERA',
'SAUCE_IE',
'SAUCE_EDGE',
'SAUCE_IOS',
'SAUCE_ANDROID'
];
options.forEach(function (opt) {
if (process.env[opt]) {
runAll = false;
}
});
// Chrome
if (runAll || process.env.SAUCE_CHROME) {
customLaunchers.SL_Chrome = createCustomLauncher('chrome');
// customLaunchers.SL_ChromeDev = createCustomLauncher('chrome', 'dev');
// customLaunchers.SL_ChromeBeta = createCustomLauncher('chrome', 'beta');
}
// Firefox
if (runAll || process.env.SAUCE_FIREFOX) {
customLaunchers.SL_Firefox = createCustomLauncher('firefox');
// customLaunchers.SL_FirefoxDev = createCustomLauncher('firefox', 'dev');
// customLaunchers.SL_FirefoxBeta = createCustomLauncher('firefox', 'beta');
}
// Safari
if (runAll || process.env.SAUCE_SAFARI) {
// customLaunchers.SL_Safari7 = createCustomLauncher('safari', 7);
// customLaunchers.SL_Safari8 = createCustomLauncher('safari', 8);
customLaunchers.SL_Safari9 = createCustomLauncher(
"safari",
9.0,
"OS X 10.11"
);
customLaunchers.SL_Safari10 = createCustomLauncher(
"safari",
"10.1",
"macOS 10.12"
);
customLaunchers.SL_Safari11 = createCustomLauncher(
"safari",
"11.1",
"macOS 10.13"
);
}
// Opera
if (runAll || process.env.SAUCE_OPERA) {
// TODO The available versions of Opera are too old and lack basic APIs
// customLaunchers.SL_Opera11 = createCustomLauncher('opera', 11, 'Windows XP');
// customLaunchers.SL_Opera12 = createCustomLauncher('opera', 12, 'Windows 7');
}
// IE
if (runAll || process.env.SAUCE_IE) {
customLaunchers.SL_IE11 = createCustomLauncher('internet explorer', 11, 'Windows 8.1');
}
// Edge
if (runAll || process.env.SAUCE_EDGE) {
customLaunchers.SL_Edge = createCustomLauncher('microsoftedge', null, 'Windows 10');
}
// IOS
if (runAll || process.env.SAUCE_IOS) {
// TODO IOS7 capture always timesout
// customLaunchers.SL_IOS7 = createCustomLauncher('iphone', '7.1', 'OS X 10.10');
// TODO Mobile browsers are causing failures, possibly from too many concurrent VMs
// customLaunchers.SL_IOS8 = createCustomLauncher('iphone', '8.4', 'OS X 10.10');
// customLaunchers.SL_IOS9 = createCustomLauncher('iphone', '9.2', 'OS X 10.10');
}
// Android
if (runAll || process.env.SAUCE_ANDROID) {
// TODO Mobile browsers are causing failures, possibly from too many concurrent VMs
// customLaunchers.SL_Android4 = createCustomLauncher('android', '4.4', 'Linux');
// customLaunchers.SL_Android5 = createCustomLauncher('android', '5.1', 'Linux');
}
browsers = Object.keys(customLaunchers);
} else if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') {
console.log(
'Cannot run on Sauce Labs as encrypted environment variables are not available to PRs. ' +
'Running on Travis.'
);
browsers = ['Firefox'];
} else {
console.log('Running locally since SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are not set.');
browsers = ['Firefox', 'Chrome', 'Safari', 'Opera'];
}
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-ajax', 'jasmine', 'sinon'],
// list of files / patterns to load in the browser
files: [
'test/specs/__helpers.js',
'test/specs/**/*.spec.js',
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'test/specs/__helpers.js': ['webpack', 'sourcemap'],
'test/specs/**/*.spec.js': ['webpack', 'sourcemap']
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
// Disable code coverage, as it's breaking CI:
// reporters: ['dots', 'coverage', 'saucelabs'],
reporters: ['dots', 'saucelabs'],
// web server port
port: 9876,
// Increase timeouts to prevent the issue with disconnected tests (https://goo.gl/nstA69)
captureTimeout: 4 * 60 * 1000,
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 1,
browserNoActivityTimeout: 4 * 60 * 1000,
// enable / disable colors in the output (reporters and logs)
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,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: browsers,
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Webpack config
webpack: {
cache: true,
devtool: 'inline-source-map',
// Disable code coverage, as it's breaking CI
// module: {
// postLoaders: [
// {
// test: /\.js$/,
// exclude: /(node_modules|test)/,
// loader: 'istanbul-instrumenter'
// }
// ]
// },
externals: [
{
'./adapters/http': 'var undefined'
}
],
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('test')
})
]
},
webpackServer: {
stats: {
colors: true
}
},
// Coverage reporting
coverageReporter: {
type: 'lcov',
dir: 'coverage/',
subdir: '.'
},
// SauceLabs config
sauceLabs: {
recordScreenshots: false,
connectOptions: {
// port: 5757,
logfile: 'sauce_connect.log'
},
public: 'public'
},
customLaunchers: customLaunchers
});
};