-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
karma.conf.js
110 lines (106 loc) · 3.25 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
const { chromium } = require('@playwright/test');
const webpack = require('webpack');
const CI = Boolean(process.env.CI);
process.env.CHROME_BIN ||= chromium.executablePath();
// Karma configuration
module.exports = function setKarmaConfig(config) {
const baseConfig = {
basePath: '../',
browsers: ['chromeHeadless'],
browserDisconnectTimeout: 3 * 60 * 1000, // default 2000
browserDisconnectTolerance: 1, // default 0
browserNoActivityTimeout: 6 * 60 * 1000, // default 10000
colors: true,
client: {
mocha: {
// Some BrowserStack browsers can be slow.
timeout: (process.env.CIRCLECI === 'true' ? 5 : 2) * 1000,
},
},
frameworks: (process.env.PARALLEL === 'true' ? ['parallel'] : []).concat(['mocha', 'webpack']),
files: [
{
pattern: 'test/karma.tests.js',
watched: true,
served: true,
included: true,
},
],
plugins: (process.env.PARALLEL === 'true' ? ['karma-parallel'] : []).concat([
'karma-mocha',
'karma-chrome-launcher',
'karma-sourcemap-loader',
'karma-webpack',
]),
/**
* 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'],
},
reporters: ['dots'],
webpack: {
mode: 'development',
devtool: CI ? 'inline-source-map' : 'eval-source-map',
target: 'web',
optimization: {
nodeEnv: false, // https://x.com/wsokra/status/1378643098893443072
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"test"',
CI: JSON.stringify(process.env.CI),
KARMA: 'true',
},
}),
],
module: {
rules: [
{
test: /\.(js|ts|tsx)$/,
loader: 'babel-loader',
exclude: /node_modules\/.*\/node_modules\/(?!@mui\/monorepo)/,
},
],
},
resolve: {
extensions: ['.js', '.ts', '.tsx'],
fallback: {
fs: false, // Some tests import fs,
stream: require.resolve('stream-browserify'), // util > inherits breaks with `false`
path: false,
},
},
},
webpackMiddleware: {
noInfo: true,
writeToDisk: CI,
},
customLaunchers: {
chromeHeadless: {
base: 'ChromeHeadless',
flags: [
'--no-sandbox',
// running headless chrome in a virtualized environment forces pointer type to default to `NONE`
// to mimic "desktop" environment more correctly we force blink to have `pointer: fine` support
// this allows correct pickers behavior, where their rendering depends on this condition
// https://github.com/microsoft/playwright/issues/7769#issuecomment-1205106311
'--blink-settings=primaryPointerType=4',
// increasing default `800x600` size to certain window sizing cases to consider browser as "mobile"
// i.e.: date time pickers do check height > 667
'--window-size=1000,800',
],
},
},
singleRun: CI,
};
config.set(baseConfig);
};