-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma.conf.js
181 lines (161 loc) · 4.86 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
const path = require('path');
const alias = require('@rollup/plugin-alias');
const nodeResolve = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const istanbul = require('rollup-plugin-istanbul');
const babel = require('rollup-plugin-babel');
const minimist = require('minimist');
const c = require('ansi-colors');
const argv = minimist(process.argv.slice(2));
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),
// Get a Sauce Labs account and remove the `false`
sauceLabs = false && ci && !pullRequest && masterBranch;
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',
platform: 'OS X 10.11',
},
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
argv.open ? '' : '--headless',
'--disable-gpu',
'--disable-translate',
'--disable-extensions',
// Without a remote debugging port, Google Chrome exits immediately.
'--remote-debugging-port=9333',
// Removes that crazy long prefix HeadlessChrome 79.0.3945 (Mac OS X 10.15.2)
'--user-agent=',
],
},
};
module.exports = function (config) {
config.set({
browsers: sauceLabs
? Object.keys(sauceLabsLaunchers)
: Object.keys(localLaunchers),
customLaunchers: sauceLabs ? sauceLabsLaunchers : localLaunchers,
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,
},
// browserLogOptions: { terminal: true },
// browserConsoleLogOptions: { terminal: true },
browserConsoleLogOptions: {
level: 'warn', // Filter on warn messages.
format: '%b %T: %m',
terminal: true,
},
browserNoActivityTimeout: 60 * 60 * 1000,
// Use only one browser, works better with open source Sauce Labs remote testing
concurrency: 2,
captureTimeout: 0,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_ERROR,
client: { captureConsole: !!argv.console },
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['tap-pretty'].concat(
coverage ? 'coverage' : [],
sauceLabs ? 'saucelabs' : []
),
tapReporter: {
prettify: require('faucet'), // require('tap-spec')
},
formatError(msg) {
msg = msg.replace(/\([^<]+/gm, '');
msg = msg.replace(/(\bat\s.*)/gms, argv.stack ? c.dim('$1') : '');
return msg;
},
coverageReporter: {
dir: path.join(__dirname, 'coverage'),
reporters: [
{ type: 'text' },
{ type: 'html' },
{ type: 'lcovonly', subdir: '.', file: 'lcov.info' },
],
},
frameworks: ['tap'],
files: [
'https://polyfill.io/v3/polyfill.min.js?features=Element.prototype.dataset%2CArray.from',
{
pattern: config.grep || 'test/**/*.js',
watched: false,
},
],
preprocessors: {
'test/**/*.js': ['rollup'],
},
rollupPreprocessor: {
output: {
format: 'iife', // Helps prevent naming collisions.
name: 'library', // Required for 'iife' format.
sourcemap: 'inline', // Sensible for testing.
},
preserveSymlinks: true,
plugins: [
alias({
entries: {
tape: 'tape-browser',
libraryTest: __dirname + 'src/index.js',
},
}),
nodeResolve(),
commonjs(),
istanbul({
include: config.grep
? config.grep.replace('/test/', '/src/')
: 'src/**/*.js',
}),
sauceLabs &&
babel({
include: ['src/**'],
}),
].filter(Boolean),
onwarn: (msg) => /eval/.test(msg) && void 0,
},
});
};