-
Notifications
You must be signed in to change notification settings - Fork 68
/
karma.conf.js
194 lines (175 loc) · 5.02 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
// Karma configuration
// Generated on Tue Oct 03 2017 13:01:40 GMT-0700 (PDT)
let local = false
module.exports = function (config) {
'use strict'
let browsers
let reporters
let jsonReporter = {
stdout: false,
outputFile: 'browser-results.json', // defaults to none
}
switch (process.env.TEST_ENV) {
case 'browser':
browsers = Object.keys(customLaunchers)
reporters = ['dots', 'json', 'saucelabs']
break
// default is local
default:
local = true
browsers = ['Chrome']
reporters = ['progress', 'json']
}
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: ['mocha', 'chai'],
// list of files / patterns to load in the browser
files: [
// Load the babel polyfill
'node_modules/babel-polyfill/dist/polyfill.js',
// We need to use singl entry file to avoid circular import error between
// `aspect.js` and `conversion.js`
'src/index.js',
'test/*.spec.js',
],
webpack: {
// kind of a copy of your webpack config
devtool: 'inline-source-map', // just do inline source maps instead of the default
mode: 'production',
module: {
rules: [
{
test: /(\.jsx|\.js)$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
},
},
{
// We need to transpile chai-as-promised to ES5
test: require.resolve('chai-as-promised'),
use: {
loader: 'babel-loader',
},
},
],
},
},
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
// add webpack as preprocessor
'src/*.js': ['webpack', 'sourcemap'],
'test/*.js': ['webpack', 'sourcemap'],
// We need to transpile chai-as-promised to ES5
[require.resolve('chai-as-promised')]: ['webpack'],
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: reporters,
// Write testing results to json file.
jsonReporter: jsonReporter,
// web server port
port: 9876,
// 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: local,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
// browsers: ['Chrome'],
sauceLabs: {
testName: 'Futil-js browser tests',
recordVideo: local,
recordScreenshots: local,
},
captureTimeout: 360 * 1000,
browserNoActivityTimeout: 600 * 1000,
browserDisconnectTimeout: 60 * 1000,
browserDisconnectTolerance: 3,
browsers: browsers,
customLaunchers: !local && customLaunchers,
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: !local,
// Concurrency level
// how many browser should be started simultaneous
concurrency: 5,
})
}
// Browsers to run on Sauce Labs
// Check out https://saucelabs.com/platforms for all browser/OS combos
// UPDATED to match angular's config https://github.com/angular/angular.js/blob/master/karma-shared.conf.js
let customLaunchers = {
SL_Chrome: {
base: 'SauceLabs',
browserName: 'chrome',
version: 'latest',
},
'SL_Chrome-1': {
base: 'SauceLabs',
browserName: 'chrome',
version: 'latest-1',
},
SL_Firefox: {
base: 'SauceLabs',
browserName: 'firefox',
version: 'latest',
},
'SL_Firefox-1': {
base: 'SauceLabs',
browserName: 'firefox',
version: 'latest-1',
},
'SL_Safari-1': {
base: 'SauceLabs',
browserName: 'safari',
version: 'latest-1',
},
SL_Safari: {
base: 'SauceLabs',
browserName: 'safari',
version: 'latest',
},
// 'SL_IE_9': {
// base: 'SauceLabs',
// browserName: 'internet explorer',
// platform: 'Windows 2008',
// version: '9'
// },
SL_IE_11: {
base: 'SauceLabs',
browserName: 'internet explorer',
platform: 'Windows 8.1',
version: '11',
},
SL_EDGE: {
base: 'SauceLabs',
browserName: 'microsoftedge',
platform: 'Windows 10',
version: 'latest',
},
'SL_EDGE-1': {
base: 'SauceLabs',
browserName: 'microsoftedge',
platform: 'Windows 10',
version: 'latest-1',
},
SL_iOS: {
base: 'SauceLabs',
browserName: 'iphone',
version: 'latest',
},
'SL_iOS-1': {
base: 'SauceLabs',
browserName: 'iphone',
version: 'latest-1',
},
}