forked from preactjs/preact
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
180 lines (161 loc) · 4.35 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
/*eslint no-var:0, object-shorthand:0 */
var coverage = String(process.env.COVERAGE) === 'true',
ci = String(process.env.CI).match(/^(1|true)$/gi),
pullRequest = !String(process.env.TRAVIS_PULL_REQUEST).match(/^(0|false|undefined)$/gi),
masterBranch = String(process.env.TRAVIS_BRANCH).match(/^master$/gi),
sauceLabs = ci && !pullRequest && masterBranch,
performance = !coverage && String(process.env.PERFORMANCE) !== 'false',
webpack = require('webpack'),
path = require('path');
var sauceLabsLaunchers = {
sl_chrome: {
base: 'SauceLabs',
browserName: 'chrome',
platform: 'Windows 10'
},
sl_firefox: {
base: 'SauceLabs',
browserName: 'firefox',
platform: 'Windows 10'
},
sl_safari: {
base: 'SauceLabs',
browserName: 'Safari',
version: '11',
platform: 'OS X 10.13'
},
sl_edge: {
base: 'SauceLabs',
browserName: 'MicrosoftEdge',
platform: 'Windows 10'
},
sl_ie_11: {
base: 'SauceLabs',
browserName: 'internet explorer',
version: '11.0',
platform: 'Windows 7'
}
};
var localLaunchers = {
ChromeNoSandboxHeadless: {
base: 'Chrome',
flags: [
'--no-sandbox',
// See https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
'--headless',
'--disable-gpu',
// Without a remote debugging port, Google Chrome exits immediately.
'--remote-debugging-port=9333'
]
}
};
module.exports = function(config) {
config.set({
browsers: sauceLabs
? Object.keys(sauceLabsLaunchers)
: Object.keys(localLaunchers),
frameworks: ['source-map-support', 'mocha', 'chai-sinon'],
reporters: ['mocha'].concat(
coverage ? 'coverage' : [],
sauceLabs ? 'saucelabs' : []
),
coverageReporter: {
dir: path.join(__dirname, 'coverage'),
reporters: [
{ type: 'text-summary' },
{ type: 'html' },
{ type: 'lcovonly', subdir: '.', file: 'lcov.info' }
]
},
mochaReporter: {
showDiff: true
},
browserLogOptions: { terminal: true },
browserConsoleLogOptions: { terminal: true },
browserNoActivityTimeout: 5 * 60 * 1000,
// Use only two browsers concurrently, works better with open source Sauce Labs remote testing
concurrency: 2,
captureTimeout: 0,
sauceLabs: {
build: 'CI #' + process.env.TRAVIS_BUILD_NUMBER + ' (' + process.env.TRAVIS_BUILD_ID + ')',
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER || ('local'+require('./package.json').version),
connectLocationForSERelay: 'localhost',
connectPortForSERelay: 4445,
startConnect: false
},
customLaunchers: sauceLabs ? sauceLabsLaunchers : localLaunchers,
files: [
{ pattern: 'test/polyfills.js', watched: false },
{ pattern: config.grep || '{debug,hooks,compat,test-utils,}/test/{browser,shared}/**.test.js', watched: false }
],
preprocessors: {
'{debug,hooks,compat,test-utils,}/test/**/*': ['webpack', 'sourcemap']
},
webpack: {
output: {
filename: '[name].js'
},
mode: 'development',
devtool: 'inline-source-map',
module: {
noParse: [
/benchmark\.js$/
],
/* Transpile source and test files */
rules: [
{
enforce: 'pre',
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
comments: false,
compact: true,
plugins: coverage ?
[['istanbul', {
exclude: [
// Default config
'coverage/**',
'dist/**',
'test/**',
'test{,-*}.js',
'**/*.test.js',
'**/__tests__/**',
'**/node_modules/**',
// Our custom extension
'{debug,hooks,compat,test-utils}/test/**/*'
]
}]] : []
}
}
]
},
resolve: {
// The React DevTools integration requires preact as a module
// rather than referencing source files inside the module
// directly
alias: {
'preact/compat': path.join(__dirname, './compat/src'),
'preact/hooks': path.join(__dirname, './hooks/src'),
'preact/test-utils': path.join(__dirname, './test-utils/src'),
preact: path.join(__dirname, './src')
}
},
plugins: [
new webpack.DefinePlugin({
coverage: coverage,
NODE_ENV: JSON.stringify(process.env.NODE_ENV || ''),
ENABLE_PERFORMANCE: performance,
DISABLE_FLAKEY: !!String(process.env.FLAKEY).match(/^(0|false)$/gi)
})
],
performance: {
hints: false
}
},
webpackMiddleware: {
noInfo: true,
stats: 'errors-only'
}
});
};