-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathkarma.conf.ts
89 lines (77 loc) · 2.38 KB
/
karma.conf.ts
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
/*
* SPDX-FileCopyrightText: 2022 Tim Perry <tim@httptoolkit.tech>
* SPDX-License-Identifier: Apache-2.0
*/
const CONTINUOUS = process.env.CONTINUOUS_TEST === 'true';
const HEADFUL = process.env.HEADFUL_TEST === 'true';
import * as ChildProcess from 'child_process';
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill';
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
if (CONTINUOUS) {
const adminProc = ChildProcess.spawn(
"./node_modules/.bin/node-dev",
[
'--notify=false',
'./test/start-test-admin-server.ts'
],
{ stdio: 'inherit' }
);
process.on('exit', () => adminProc.kill());
adminProc.on('exit', (code) => {
process.exit(code ?? 0); // Signalled = null = we killed it
});
} else {
require('./test/start-test-admin-server');
}
module.exports = function(config: any) {
config.set({
frameworks: ['mocha', 'chai'],
files: [
'test/**/*.spec.ts'
],
preprocessors: {
'src/**/*.ts': ['esbuild'],
'test/**/*.ts': ['esbuild']
},
esbuild: {
format: 'esm',
target: 'esnext',
plugins: [
NodeModulesPolyfillPlugin(),
NodeGlobalsPolyfillPlugin({
process: true,
buffer: true
})
]
},
plugins: [
'karma-chrome-launcher',
'karma-chai',
'karma-mocha',
'karma-mocha-reporter',
'karma-esbuild'
],
reporters: ['mocha'],
mochaReporter: {
showDiff: true
},
port: 9876,
logLevel: config.LOG_INFO,
browsers: HEADFUL
? ['ChromeWithFakeMedia']
: ['ChromeHeadlessWithFakeMedia'],
customLaunchers: {
ChromeHeadlessWithFakeMedia: {
base: 'ChromeHeadless',
flags: ['--use-fake-ui-for-media-stream', '--use-fake-device-for-media-stream']
},
ChromeWithFakeMedia: {
base: 'Chrome',
flags: ['--use-fake-ui-for-media-stream', '--use-fake-device-for-media-stream']
}
},
autoWatch: CONTINUOUS,
singleRun: !CONTINUOUS,
concurrency: Infinity
});
};