-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathkarma.conf.js
156 lines (150 loc) · 5.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
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
// Based on fast-components configuration:
// https://github.com/microsoft/fast/blob/6549309c1ed2dea838561d23fea6337ef16d7908/packages/web-components/fast-components/karma.conf.js
// Coverage from the fast configuration removed due to lack of Webpack 5 support:
// https://github.com/webpack-contrib/istanbul-instrumenter-loader/issues/110
const playwright = require('playwright');
process.env.WEBKIT_HEADLESS_BIN = playwright.webkit.executablePath();
process.env.WEBKIT_BIN = playwright.webkit.executablePath();
process.env.FIREFOX_BIN = playwright.firefox.executablePath();
process.env.CHROME_BIN = playwright.chromium.executablePath();
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',
'--force-prefers-reduced-motion',
'--lang=en-US',
'--time-zone-for-testing=America/Chicago'
];
module.exports = config => {
const options = {
basePath,
browserDisconnectTimeout: 10000,
processKillTimeout: 10000,
frameworks: [
'source-map-support',
'jasmine',
'webpack',
'jasmine-spec-tags'
],
plugins: [
'karma-jasmine',
'karma-jasmine-html-reporter',
'karma-jasmine-spec-tags',
'karma-webpack',
'karma-source-map-support',
'karma-sourcemap-loader',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-webkit-launcher'
],
files: ['dist/esm/utilities/tests/setup.js'],
preprocessors: {
'dist/esm/utilities/tests/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,
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: ['kjhtml'],
browsers: ['ChromeHeadlessOpt'],
customLaunchers: {
ChromeDebugging: {
base: 'Chrome',
flags: [...commonChromeFlags, '--remote-debugging-port=9333'],
debug: true
},
ChromeHeadlessOpt: {
base: 'ChromeHeadless',
flags: [...commonChromeFlags]
},
FirefoxDebugging: {
base: 'Firefox',
debug: true
},
WebkitDebugging: {
base: 'Webkit',
debug: true
}
},
client: {
jasmine: {
stopSpecOnExpectationFailure: false
},
captureConsole: true
},
logLevel: config.LOG_ERROR, // to disable the WARN 404 for image requests
customHeaders: [
// Test under the OWASP Basic non-strict CSP Policy
// See: https://cheatsheetseries.owasp.org/cheatsheets/Content_Security_Policy_Cheat_Sheet.html#basic-non-strict-csp-policy
// Need script-src 'unsafe-inline' to support karma behavior
// See: https://github.com/karma-runner/karma/issues/3260
// Need style-src 'unsafe-inline' to support FAST
// See: https://github.com/microsoft/fast/issues/4510
// Need worker-src blob: to support current worker loading pattern
{
match: '\\.html',
name: 'Content-Security-Policy',
value: "default-src 'self'; frame-ancestors 'self'; form-action 'self'; object-src 'none'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; worker-src 'self' blob: ;"
}
]
};
config.set(options);
};