forked from jhildenbiddle/css-vars-ponyfill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma.conf.js
183 lines (172 loc) · 6.23 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
// Dependencies
// =============================================================================
const pkg = require('./package');
const saucelabs = require('./saucelabs.config');
// Variables
// =============================================================================
const files = {
fixtures: './tests/fixtures/**/*',
test : './tests/**/*.test.js'
};
// Settings
// =============================================================================
const settings = {
files: [
'node_modules/@babel/polyfill/dist/polyfill.js',
files.test,
// Served only (Access in tests by prepending /base/ to path)
{ pattern: files.fixtures, included: false, served: true, watched: true }
],
preprocessors: {
[files.fixtures]: ['file-fixtures'],
[files.test] : ['eslint', 'webpack', 'sourcemap']
},
frameworks: ['mocha', 'chai'],
reporters : ['mocha', 'coverage-istanbul'],
fileFixtures: {
stripPrefix: 'tests/fixtures/'
},
webpack: {
mode : 'development',
module: {
rules: [
{
test : /\.js$/,
exclude: [/node_modules/],
use : [
{
loader : 'babel-loader',
options: {
presets: [
[
'@babel/env',
{
targets: {
browsers: ['ie >= 9']
}
}
]
],
plugins: [
'@babel/plugin-transform-object-assign',
'transform-custom-element-classes',
['istanbul', { exclude: 'tests/*' }]
]
},
}
]
}
]
}
},
webpackMiddleware: {
// https://webpack.js.org/configuration/stats/
stats: 'minimal'
},
// Code coverage
// https://github.com/mattlewis92/karma-coverage-istanbul-reporter
coverageIstanbulReporter: {
reports : ['lcovonly', 'text-summary'],
combineBrowserReports : true,
fixWebpackSourcePaths : true,
skipFilesWithNoCoverage: true
},
mochaReporter: {
// https://www.npmjs.com/package/karma-mocha-reporter
output: 'autowatch'
},
autoWatch : false,
colors : true,
concurrency: Infinity,
port : 9876,
singleRun : true,
// Prevent disconnect in Firefox/Safari
// https://support.saucelabs.com/hc/en-us/articles/225104707-Karma-Tests-Disconnect-Particularly-When-Running-Tests-on-Safari
browserDisconnectTimeout : 1000*10, // default 2000
browserDisconnectTolerance: 1, // default 0
browserNoActivityTimeout : 1000*30, // default 10000
captureTimeout : 1000*60, // default 60000
client: {
// Prevent browser messages from appearing in terminal
captureConsole: false
// mocha: {
// timeout: 1000*20 // default 2000
// }
}
};
// Export
// =============================================================================
module.exports = function(config) {
const isRemote = Boolean(process.argv.indexOf('--remote') > -1);
// Remote test
if (isRemote) {
// Browsers
// https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/
settings.customLaunchers = {
sl_chrome: {
base : 'SauceLabs',
browserName: 'Chrome',
platform : 'Windows 10',
version : '48.0'
},
sl_edge: {
base : 'SauceLabs',
browserName: 'MicrosoftEdge',
platform : 'Windows 10',
version : '14.14393'
},
sl_firefox: {
base : 'SauceLabs',
browserName: 'Firefox',
platform : 'Windows 10',
version : '32'
},
sl_ie_9: {
base : 'SauceLabs',
browserName: 'Internet Explorer',
platform : 'Windows 7',
version : '9.0'
},
sl_safari: {
base : 'SauceLabs',
browserName: 'Safari',
platform : 'OS X 10.10',
version : '8.0'
}
};
settings.browsers = Object.keys(settings.customLaunchers);
// SauceLabs
settings.reporters.push('saucelabs');
settings.sauceLabs = {
username : saucelabs.username || process.env.SAUCE_USERNAME,
accessKey : saucelabs.accessKey || process.env.SAUCE_ACCESS_KEY,
testName : `${pkg.name} (karma)`,
recordScreenshots: false,
recordVideo : false
};
// Travis CI
if ('TRAVIS' in process.env) {
// Use custom hostname to prevent Safari disconnects
// https://support.saucelabs.com/hc/en-us/articles/115010079868-Issues-with-Safari-and-Karma-Test-Runner
settings.hostname = 'travis.dev';
}
}
// Local
else {
settings.browsers = [
'ChromeHeadless'
// 'jsdom' // SSR Testing
];
settings.webpack.devtool = 'inline-source-map';
settings.coverageIstanbulReporter.reports.push('html');
// eslint-disable-next-line
console.log([
'============================================================\n',
`KARMA: localhost:${settings.port}/debug.html\n`,
'============================================================\n'
].join(''));
}
// Logging: LOG_DISABLE, LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG
settings.logLevel = config.LOG_INFO;
config.set(settings);
};