forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.profile.js
182 lines (175 loc) · 5.11 KB
/
karma.conf.profile.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
const path = require('path');
const { chromium } = require('playwright');
const webpack = require('webpack');
const workspaceRoot = path.resolve(__dirname, '../');
const browserStack = {
username: process.env.BROWSERSTACK_USERNAME,
accessKey: process.env.BROWSERSTACK_ACCESS_KEY,
build: `mui-core-profile-${new Date().toISOString()}`,
};
process.env.CHROME_BIN = chromium.executablePath();
// Karma configuration
module.exports = function setKarmaConfig(config) {
const baseConfig = {
basePath: '../',
browsers: ['chromeHeadless'],
browserDisconnectTimeout: 120000, // default 2000
browserDisconnectTolerance: 1, // default 0
browserNoActivityTimeout: 300000, // default 10000
colors: true,
frameworks: ['mocha', 'webpack'],
files: [
{
pattern: 'test/karma.tests.js',
watched: false,
},
{
pattern: 'test/assets/*.png',
watched: false,
included: false,
served: true,
},
],
plugins: [
'karma-mocha',
'karma-chrome-launcher',
'karma-sourcemap-loader',
'karma-webpack',
require.resolve('./utils/KarmaReporterReactProfiler'),
],
/**
* possible values:
* - config.LOG_DISABLE
* - config.LOG_ERROR
* - config.LOG_WARN
* - config.LOG_INFO
* - config.LOG_DEBUG
*/
logLevel: config.LOG_INFO,
port: 9876,
preprocessors: {
'test/karma.tests.js': ['webpack', 'sourcemap'],
},
proxies: {
'/fake.png': '/base/test/assets/fake.png',
'/fake2.png': '/base/test/assets/fake2.png',
},
reporters: ['dots', 'profiler'],
reactProfilerReporter: {
outputDir: path.join(workspaceRoot, 'tmp/react-profiler-report/karma'),
},
webpack: {
// TODO: profile in production
mode: 'development',
// https://webpack.js.org/configuration/devtool/#devtool
devtool: 'eval-cheap-source-map',
optimization: {
// Helps debugging and build perf.
// Bundle size is irrelevant for local serving.
minimize: false,
// TODO: profile in production
nodeEnv: 'test',
},
plugins: [
new webpack.DefinePlugin({
'process.env.CI': JSON.stringify(process.env.CI),
'process.env.KARMA': JSON.stringify(true),
'process.env.TEST_GATE': JSON.stringify('enable-dispatching-profiler'),
}),
new webpack.ProvidePlugin({
// required by enzyme > cheerio > parse5 > util
process: 'process/browser.js',
}),
],
module: {
rules: [
{
test: /\.(js|ts|tsx)$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
envName: 'stable',
},
},
],
},
resolve: {
alias: {
// "How to use profiling in production"
// https://gist.github.com/bvaughn/25e6233aeb1b4f0cdb8d8366e54a3977#react-dom1660--scheduler0100
'react-dom$': 'react-dom/profiling',
},
extensions: ['.js', '.ts', '.tsx'],
fallback: {
// needed by sourcemap
fs: false,
path: false,
// needed by enzyme > cheerio
stream: false,
},
},
// TODO: 'browserslist:modern'
// See https://github.com/webpack/webpack/issues/14203
target: 'web',
},
webpackMiddleware: {
noInfo: true,
writeToDisk: Boolean(process.env.CI),
},
customLaunchers: {
chromeHeadless: {
base: 'ChromeHeadless',
flags: ['--no-sandbox'],
},
},
singleRun: Boolean(process.env.CI),
};
let newConfig = baseConfig;
if (browserStack.accessKey) {
newConfig = {
...baseConfig,
browserStack,
browsers: baseConfig.browsers.concat(['chrome', 'firefox', 'safari', 'edge']),
plugins: baseConfig.plugins.concat(['karma-browserstack-launcher']),
customLaunchers: {
...baseConfig.customLaunchers,
chrome: {
base: 'BrowserStack',
os: 'OS X',
os_version: 'Catalina',
browser: 'chrome',
// We support Chrome 90.x
// However, >=88 fails on seemingly all focus-related tests.
// TODO: Investigate why.
browser_version: '87.0',
},
// No accurate performance timings (integer precision instead of double).
firefox: {
base: 'BrowserStack',
os: 'Windows',
os_version: '10',
browser: 'firefox',
browser_version: '78.0',
},
// No accurate performance timings (integer precision instead of double).
safari: {
base: 'BrowserStack',
os: 'OS X',
os_version: 'Catalina',
browser: 'safari',
// We support 12.5 on iOS.
// However, 12.x is very flaky on desktop (mobile is always flaky).
browser_version: '13.0',
},
edge: {
base: 'BrowserStack',
os: 'Windows',
os_version: '10',
browser: 'edge',
browser_version: '91.0',
},
},
};
}
config.set(newConfig);
};