-
Notifications
You must be signed in to change notification settings - Fork 51
/
karma.config.cjs
59 lines (47 loc) · 1.58 KB
/
karma.config.cjs
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
const karmaChromeLauncher = require('karma-chrome-launcher');
const karmaCoverage = require('karma-coverage');
const karmaMocha = require('karma-mocha');
const karmaVite = require('karma-vite');
const karmaSpecReporter = require('karma-spec-reporter');
const isCI = !!process.env.CI;
const watch = !!process.argv.find((arg) => arg.includes('watch')) && !isCI;
const coverage = !!process.argv.find((arg) => arg.includes('--coverage'));
module.exports = (config) => {
config.set({
basePath: '',
plugins: [karmaMocha, karmaChromeLauncher, karmaVite, karmaCoverage, karmaSpecReporter],
browsers: ['ChromeHeadlessNoSandbox'],
// you can define custom flags
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox', '--disable-setuid-sandbox', isCI ? undefined : '--disable-dev-shm-usage'].filter(
Boolean,
),
},
},
captureTimeout: 60000, // it was already there
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 1,
browserNoActivityTimeout: 60000, //by default 10000
frameworks: ['vite', 'mocha'],
files: [
{
pattern: 'test/**/*.spec.ts',
type: 'module',
watched: false,
served: false,
},
],
reporters: ['spec', coverage && 'coverage'].filter(Boolean),
autoWatch: watch,
singleRun: !watch,
coverageReporter: {
dir: '.coverage/',
reporters: [!isCI && { type: 'html', subdir: 'html' }, { type: 'lcovonly', subdir: '.' }].filter(Boolean),
},
vite: {
autoInit: true,
},
});
};