This repository has been archived by the owner on Oct 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
149 lines (127 loc) · 3.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
const path = require('path')
const alias = require('@rollup/plugin-alias')
const commonjs = require('rollup-plugin-commonjs')
const nodeResolve = require('rollup-plugin-node-resolve')
const replace = require('rollup-plugin-replace')
const typescript = require('rollup-plugin-typescript')
const react = require('react')
module.exports = function(config) {
const chromeFlags = [
// '--autoplay-policy=no-user-gesture-required',
'--disable-gpu',
'--disable-web-security',
'--deterministic-fetch',
'--disable-site-isolation-trials',
'--lang=en_US',
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-ipc-flooding-protection',
'--enable-logging',
'--v=1',
// '--vmodule=console=1',
]
const firefoxFlags = {
'media.autoplay.enabled': true,
'media.block-autoplay-until-in-foreground': false,
'security.fileuri.strict_origin_policy': false,
}
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
frameworks: ['parallel', 'jasmine'],
client: {
captureConsole: true,
jasmine: {
timeoutInterval: 15000,
},
},
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
browserConsoleLogOptions: {
level: 'log',
format: '%b %T: %m',
terminal: true,
},
files: [
/**
* Make sure to disable Karma’s file watcher
* because the rollup preprocessor will use its own.
*/
{ pattern: 'src/**/*.browser.test.ts', watched: false },
{ pattern: 'src/**/*.browser.test.tsx', watched: false },
],
preprocessors: {
'src/**/*.ts*': ['rollup'],
},
rollupPreprocessor: {
treeshake: false,
output: {
format: 'iife', // Helps prevent naming collisions.
name: 'reactUniversalPlayer', // Required for 'iife' format.
sourcemap: 'inline',
},
plugins: [
alias({
entries: {
'react-dom/server': path.resolve('./node_modules/react-dom/server.browser.js'),
'@sheerun/mutationobserver-shim': path.resolve(
'./node_modules/@sheerun/mutationobserver-shim/MutationObserver.js'
),
},
}),
nodeResolve({
mainFields: ['module', 'main'],
}),
commonjs({
namedExports: {
react: Object.keys(react),
'react-dom/test-utils': ['act'],
'react-dom/server.browser': ['renderToString'],
},
}),
typescript({
declaration: false,
declarationMap: false,
target: 'es2019',
}),
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
'process.env': JSON.stringify({}),
}),
],
},
// web server port
port: 9876,
colors: true,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
browsers: ['CustomHeadlessChrome', 'CustomFF'],
customLaunchers: {
CustomChrome: {
base: 'Chrome',
flags: chromeFlags,
chromeDataDir: path.resolve(__dirname, '.chrome'),
},
CustomHeadlessChrome: {
base: 'ChromeHeadless',
flags: chromeFlags,
chromeDataDir: path.resolve(__dirname, '.chrome'),
},
CustomFF: {
base: 'FirefoxHeadless',
prefs: firefoxFlags,
},
},
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,
parallelOptions: {
executors: process.env.KARMA_SINGLE ? 1 : 2,
},
})
}