forked from ModuleLoader/es-module-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
166 lines (137 loc) · 3.84 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
'use strict';
var util = require('util');
var pkg = require('./package.json');
var extend = util._extend;
var geSaLaKaCuLa = require('gesalakacula');
// No Karma options are passed after the double dash option (`--`)
// Example : karma start --single-run -- --polyfill
// >> { _: [], polyfill: true }
var _argv = process.argv;
var argv = require('minimist')(_argv.slice(_argv.indexOf('--') + 1));
var options = extend({
travis: process.env.TRAVIS,
polyfill: false,
saucelabs: false,
ie8: false,
coverage: false
}, argv);
if (options.ie8) {
console.log('IE8 Mode !\n - polyfill required\n');
options.polyfill = true;
}
if (options.saucelabs) {
options.polyfill = true;
}
////
module.exports = function(config) {
var files = [
'test/_helper.js',
[options['babel'] ? 'node_modules/regenerator/runtime.js' : ''],
[!options.ie8 ? (!options['babel'] ? 'node_modules/traceur/bin/traceur.js' : 'node_modules/babel-core/browser.js') : ''],
'dist/es6-module-loader' + (options.polyfill ? '' : '-sans-promises') + '.src.js',
'test/_browser.js',
'test/browser-script-type-module.js',
'test/custom-loader.js',
[!options.ie8 ? 'test/*.spec.js' : 'test/*.normalize.spec.js'],
{pattern: 'test/{loader,loads,syntax,worker}/**/*', included: false},
{pattern: 'node_modules/when/es6-shim/Promise.js', included: false},
{pattern: 'dist/es6-module-loader*.js', included: false}
];
// Default Config
config.set({
basePath: '',
frameworks: ['mocha', 'expect'],
files: flatten(files),
reporters: ['mocha'],
browsers: ['Chrome', 'Firefox'],
client: {
mocha: {
reporter: 'html',
timeout: 8000
}
}
});
if (options.coverage) {
config.set({
reporters: ['mocha', 'coverage'],
preprocessors: {
'dist/es6-module-loader*.src.js': ['coverage']
},
coverageReporter: {
type : 'html',
dir : 'coverage/'
},
browsers: ['Chrome']
});
}
if (options.travis) {
// TRAVIS config overwrite
config.set({
singleRun: true,
reporters: ['dots'],
customLaunchers: {
'TR_Chrome': {
base: 'Chrome',
flags: ['--no-sandbox']
}
},
browsers: ['TR_Chrome', 'Firefox']
});
}
if (options.saucelabs) {
var customLaunchers = geSaLaKaCuLa({
'Windows 7': {
'internet explorer': '9..11'
}
});
// IE tests disabled for now (https://github.com/ModuleLoader/es6-module-loader/issues/295)
customLaunchers = undefined;
if (options.ie8) {
customLaunchers = geSaLaKaCuLa({
'Windows 7': {
'internet explorer': '8'
}
});
}
var now = new Date();
var buildData = options.travis ?
{
location: 'TRAVIS',
name: process.env.TRAVIS_JOB_NUMBER,
id: process.env.TRAVIS_BUILD_ID
}
:
{
location: 'LOCAL',
name: now.toString(),
id: +now
};
var build = util.format('%s #%s (%s)',
buildData.location, buildData.name, buildData.id);
console.log('SauceLabs Run\n- Build : ' + build + '\n');
config.set({
reporters: ['dots', 'saucelabs'],
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 2,
browserNoActivityTimeout: 30000,
captureTimeout: 120000,
sauceLabs: {
testName: pkg.name,
recordScreenshots: false,
build: build,
tunnelIdentifier: options.travis ?
process.env.TRAVIS_JOB_NUMBER : Math.floor(Math.random() * 1000)
}
});
if (customLaunchers)
config.set({
browsers: Object.keys(customLaunchers),
customLaunchers: customLaunchers
});
}
};
function flatten(arr) {
return arr.reduce(function(memo, val) {
return memo.concat(util.isArray(val) ? flatten(val) : val ? [val] : []);
}, []);
}