-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspecs.js
113 lines (91 loc) · 2.24 KB
/
specs.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
const os = require('os')
const path = require('path')
const {getFlag, getString} = require('@jneander/dev-utils-node').cli
const webpack = require('./webpack')
const CHROME_FLAGS = [
'--use-mock-keychain',
'--no-default-browser-check',
'--no-first-run',
'--disable-default-apps',
'--disable-popup-blocking',
'--disable-translate',
'--disable-extensions',
'--use-fake-ui-for-media-stream',
'--use-fake-device-for-media-stream',
'--allow-file-access-from-files',
]
const pattern = getString('pattern', 'src/**/*.spec.*')
const files = [
'spec-support/index.ts',
{
pattern,
watched: false,
},
]
const preprocessors = {
'src/**/*.spec.tsx': ['webpack', 'sourcemap'],
'src/**/*.spec.ts': ['webpack', 'sourcemap'],
'spec-support/index.ts': ['webpack', 'sourcemap'],
}
const browsers = []
if (getFlag('no-headless')) {
browsers.push('CustomChrome')
} else {
browsers.push('CustomChromeHeadless')
}
module.exports = function configure(config) {
const packageName = path.basename(path.join(__dirname, '..'))
config.set({
basePath: path.join(__dirname, '..'),
/*
* Make the karma-browser exchange more forgiving to avoid
* premature disconnects and build failures.
*/
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 2,
browserNoActivityTimeout: 60000,
browsers,
/*
* If the browser does not capture in given timeout (ms),
* terminate the process.
*/
captureTimeout: 30000,
client: {
mocha: {
slow: 500,
timeout: 1000,
},
},
colors: true,
customLaunchers: {
CustomChrome: {
base: 'Chrome',
flags: CHROME_FLAGS,
},
CustomChromeHeadless: {
base: 'Chrome',
flags: CHROME_FLAGS.concat([
'-incognito',
'--headless',
'--disable-gpu',
'--remote-debugging-port=9222',
]),
},
},
files,
frameworks: ['mocha', 'webpack'],
logLevel: config.LOG_INFO,
port: 9876,
preprocessors,
reporters: ['spec'],
webpackServer: {
noInfo: true,
},
webpack: {
...webpack,
output: {
path: path.join(os.tmpdir(), `${packageName}_specs_${Date.now()}`),
},
},
})
}