forked from cloudflare/cf-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
159 lines (135 loc) · 3.63 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
import minimist from 'minimist';
import defined from 'defined';
import path from 'path';
const customLaunchers = {};
const args = minimist(process.argv.slice(2), {
string: ['env', 'build-branch', 'build-number', 'suace-username', 'sauce-key'],
default: {
env: process.env.NODE_ENV,
'build-branch': process.env.BUILD_BRANCH,
'build-number': process.env.BUILD_NUMBER,
'sauce-username': process.env.SAUCE_USERNAME,
'sauce-key': process.env.SAUCE_ACCESS_KEY
}
});
args.istanbul = defined(args.istanbul, args.env !== 'CI');
args['sauce-labs'] = defined(args['sauce-labs'], args.env === 'CI');
// Overridable arguments are denoted below. Other arguments can be found in the
// [Karma configuration](http://karma-runner.github.io/0.12/config/configuration-file.html)
['chrome', 'firefox', 'iphone', 'ipad', 'android'].forEach(browser => {
customLaunchers['sl_' + browser] = {
base: 'SauceLabs',
browserName: browser
};
});
// Safari defaults to version 5 on Windows 7 (huh?)
customLaunchers.sl_safari = {
base: 'SauceLabs',
browserName: 'safari',
platform: 'OS X 10.9'
};
[9, 10, 11].forEach(version => {
customLaunchers['sl_ie_' + version] = {
base: 'SauceLabs',
browserName: 'internet explorer',
version: version
};
});
const reporters = ['mocha', 'beep'];
if (args.istanbul) {
reporters.push('coverage');
}
let filePattern;
if (args.package) {
filePattern = 'packages/' + args.package + '/test/**/*.js';
} else {
filePattern = 'packages/*/test/**/*.js';
}
// Overridable with a comma-separated list with `--browsers`
let browsers;
if (typeof args.browsers === 'string') {
browsers = args.browsers.split(',').filter(b => b !== '');
} else if (typeof args.browsers === 'boolean') {
browsers = [];
} else {
browsers = args['sauce-labs'] ? Object.keys(customLaunchers) : [
'Chrome',
// 'Firefox',
// 'Safari'
];
}
module.exports = function(config) {
config.set({
frameworks: ['browserify', 'mocha'],
files: [
{
pattern: filePattern,
watched: true,
included: true,
served: true
}
],
preprocessors: {
'packages/*/test/**/*.js': ['browserify']
},
// Overridable with a comma-separated list with `--reporters`
reporters: reporters,
// Overridable with `[--no]-colors
colors: true,
/* Overridable with `--log-level=<level>`.
*
* Possible 'level' options include:
* * disable
* * error
* * warn
* * info
* * debug
*/
logLevel: config.LOG_INFO,
// Overridable with a comma-separated list with `--browsers`
browsers: browsers,
sauceLabs: {
username: args['sauce-username'],
accessKey: args['sauce-key'],
testName: require('./package.json').name,
tags: args['build-branch'],
build: args['build-number']
},
browserify: {
debug: true,
transform: [
'babelify'
].concat(args.istanbul && [
['browserify-istanbul', {
instrumenter: require('isparta'),
ignore: [
'**/lib/**',
path.resolve(__dirname, 'utils/**')
]
}]
] || []),
configure(bundle) {
bundle.external('react/lib/ReactContext');
bundle.external('react/lib/ExecutionEnvironment');
}
},
coverageReporter: {
reporters: [
{
type: 'html'
},
{
type: 'text'
}
]
},
client: {
// '--grep' arguments are passed directly to mocha.
args: args.grep && ['--grep', args.grep],
mocha: {
reporter: 'html'
}
},
customLaunchers: customLaunchers
});
};