forked from remix-run/react-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
175 lines (155 loc) · 4.24 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
/*eslint no-console: 0*/
var webpack = require('webpack')
var path = require('path')
module.exports = function (config) {
if (process.env.RELEASE)
config.singleRun = true
var customLaunchers = {
// Browsers to run on BrowserStack.
BS_Chrome: {
base: 'BrowserStack',
os: 'Windows',
os_version: '10',
browser: 'chrome',
browser_version: '47.0'
},
BS_Firefox: {
base: 'BrowserStack',
os: 'Windows',
os_version: '10',
browser: 'firefox',
browser_version: '43.0'
},
BS_Safari: {
base: 'BrowserStack',
os: 'OS X',
os_version: 'El Capitan',
browser: 'safari',
browser_version: '9.0'
},
BS_MobileSafari: {
base: 'BrowserStack',
os: 'ios',
os_version: '8.3',
browser: 'iphone',
real_mobile: false
},
BS_MobileSafari: {
base: 'BrowserStack',
os: 'ios',
os_version: '9.1',
browser: 'iphone',
real_mobile: false
},
BS_InternetExplorer10: {
base: 'BrowserStack',
os: 'Windows',
os_version: '8',
browser: 'ie',
browser_version: '10.0'
},
BS_InternetExplorer11: {
base: 'BrowserStack',
os: 'Windows',
os_version: '10',
browser: 'ie',
browser_version: '11.0'
},
// The ancient Travis Chrome that most projects use in CI.
ChromeCi: {
base: 'Chrome',
flags: [ '--no-sandbox' ]
}
}
var isCi = process.env.CONTINUOUS_INTEGRATION === 'true'
var runCoverage = process.env.COVERAGE === 'true' || isCi
var coverageLoaders = []
var coverageReporters = []
if (runCoverage) {
coverageLoaders.push({
test: /\.js$/,
include: path.resolve('modules/'),
exclude: /__tests__/,
loader: 'isparta'
})
coverageReporters.push('coverage')
}
config.set({
customLaunchers: customLaunchers,
browsers: [ 'Chrome' ],
frameworks: [ 'mocha' ],
reporters: [ 'mocha' ].concat(coverageReporters),
files: [
'tests.webpack.js'
],
preprocessors: {
'tests.webpack.js': [ 'webpack', 'sourcemap' ]
},
webpack: {
devtool: 'inline-source-map',
module: {
loaders: [
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' }
].concat(coverageLoaders)
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('test'),
'process.env.SKIP_BC': JSON.stringify(process.env.SKIP_BC || false),
'process.env.FAIL_ON_WARNINGS': JSON.stringify(process.env.FAIL_ON_WARNINGS || false)
})
]
},
webpackServer: {
noInfo: true
},
coverageReporter: {
reporters: [
{ type: 'html', subdir: 'html' },
{ type: 'lcovonly', subdir: '.' }
]
}
})
if (process.env.USE_CLOUD) {
config.browsers = Object.keys(customLaunchers)
config.reporters[0] = 'dots'
config.browserDisconnectTimeout = 10000
config.browserDisconnectTolerance = 3
config.browserNoActivityTimeout = 30000
config.captureTimeout = 120000
if (process.env.TRAVIS) {
var buildLabel = 'TRAVIS #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')'
config.browserStack = {
username: process.env.BROWSER_STACK_USERNAME,
accessKey: process.env.BROWSER_STACK_ACCESS_KEY,
pollingTimeout: 10000,
startTunnel: true,
project: 'react-router',
build: buildLabel,
name: process.env.TRAVIS_JOB_NUMBER
}
config.singleRun = true
} else {
config.browserStack = {
username: process.env.BROWSER_STACK_USERNAME,
accessKey: process.env.BROWSER_STACK_ACCESS_KEY,
pollingTimeout: 10000,
startTunnel: true
}
}
}
}
console.log()
console.log('===')
if (process.env.SKIP_BC) {
console.warn('`SKIP_BC=1` detected: skipping backwards compatibility tests')
} else {
console.log('`SKIP_BC=1 npm run *` to skip backwards compatibility tests.')
}
if (process.env.FAIL_ON_WARNINGS) {
console.warn('`FAIL_ON_WARNINGS=1` detected: console.error will now fail tests.')
} else {
console.log('`FAIL_ON_WARNINGS=1 npm run *` to cause console warnings to throw errors.')
}
console.log('===')
console.log()