forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
147 lines (141 loc) · 3.74 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
const path = require('path');
const basePath = path.resolve(__dirname);
const commonChromeFlags = [
'--no-default-browser-check',
'--no-first-run',
'--no-sandbox',
'--no-managed-user-acknowledgment-check',
'--disable-background-timer-throttling',
'--disable-backing-store-limit',
'--disable-boot-animation',
'--disable-cloud-import',
'--disable-contextual-search',
'--disable-default-apps',
'--disable-extensions',
'--disable-infobars',
'--disable-translate',
];
module.exports = function (config) {
let browsers;
if (process.env.BROWSERS) {
browsers = [process.env.BROWSERS];
} else if (config.browsers) {
browsers = config.browsers;
} else {
browsers = ['Chrome'];
}
const setup = 'setup-browser' + (config.package ? '-' + config.package : '');
const options = {
basePath,
browserDisconnectTimeout: 10000,
processKillTimeout: 10000,
frameworks: ['source-map-support', 'mocha', 'webpack'],
plugins: [
require('karma-mocha'),
require('karma-mocha-reporter'),
require('karma-webpack'),
require('karma-source-map-support'),
require('karma-sourcemap-loader'),
require('karma-coverage-istanbul-reporter'),
require('karma-chrome-launcher'),
require('karma-firefox-launcher'),
],
files: [`dist/esm/__test__/${setup}.js`],
preprocessors: {
[`dist/esm/__test__/${setup}.js`]: ['webpack', 'sourcemap'],
},
webpackMiddleware: {
// webpack-dev-middleware configuration
// i. e.
stats: 'errors-only',
},
webpack: {
mode: 'none',
resolve: {
extensions: ['.js'],
modules: ['dist', 'node_modules'],
mainFields: ['module', 'main'],
},
devtool: 'inline-source-map',
performance: {
hints: false,
},
optimization: {
nodeEnv: false,
usedExports: true,
flagIncludedChunks: false,
sideEffects: true,
concatenateModules: true,
splitChunks: {
name: false,
},
runtimeChunk: false,
emitOnErrors: true,
checkWasmTypes: false,
minimize: false,
},
module: {
rules: [
{
test: /\.js\.map$/,
use: ['ignore-loader'],
},
{
test: /\.js$/,
enforce: 'pre',
use: [
{
loader: 'source-map-loader',
},
],
},
],
},
},
mime: {
'text/x-typescript': ['ts'],
},
reporters: [config.reporter || (process.env.CI ? 'min' : 'progress')],
browsers: browsers,
customLaunchers: {
ChromeDebugging: {
base: 'Chrome',
flags: [...commonChromeFlags, '--remote-debugging-port=9333'],
debug: true,
},
ChromeHeadlessOpt: {
base: 'ChromeHeadless',
flags: [...commonChromeFlags],
},
},
client: {
captureConsole: true,
mocha: {
bail: config['bail'],
ui: 'bdd',
timeout: 5000,
},
},
logLevel: config.LOG_ERROR, // to disable the WARN 404 for image requests
};
if (config.coverage) {
options.webpack.module.rules.push({
enforce: 'post',
exclude: /(__tests__|testing|node_modules|\.spec\.[tj]s$)/,
loader: 'istanbul-instrumenter-loader',
options: { esModules: true },
test: /\.[tj]s$/,
});
options.reporters = ['coverage-istanbul', ...options.reporters];
options.coverageIstanbulReporter = {
reports: ['html', 'text-summary', 'json', 'lcovonly', 'cobertura'],
dir: 'coverage',
};
options.junitReporter = {
outputDir: 'coverage',
outputFile: 'test-results.xml',
useBrowserName: false,
};
}
config.set(options);
};