This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.ts
60 lines (56 loc) · 1.6 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
import { Config, ConfigOptions } from 'karma'
import { KarmaTypescriptConfig } from 'karma-typescript/src/api/configuration'
import * as karmaCoverage from 'karma-coverage'
interface CustomKarmaConfigOptions extends ConfigOptions, karmaCoverage.ConfigOptions {
karmaTypescriptConfig?: KarmaTypescriptConfig
}
interface CustomKarmaConfig extends Config {
set: (config: CustomKarmaConfigOptions) => void
}
const env = process.env.NODE_ENV || ''
const isDebugMode = env.toLowerCase() === 'debug'
export default (config: CustomKarmaConfig) => {
config.set({
frameworks: [
'mocha',
'karma-typescript',
],
preprocessors: {
'**/*.ts': ['karma-typescript'],
},
files: [
{ pattern: './src/**/*.ts' },
{ pattern: './test/**/*.ts' },
],
exclude: [
'./test/node/**/*',
'./test/util/node/**/*',
'./src/**/*.node.*',
],
reporters: ['progress', 'karma-typescript'],
browsers: ['ChromeHeadless'],
customLaunchers: {
FirefoxHeadless: {
base: 'Firefox',
flags: ['-headless'],
},
},
singleRun: true,
karmaTypescriptConfig: {
tsconfig: './tsconfig.test.json',
coverageOptions: {
instrumentation: !isDebugMode,
},
reports: {
json: {
directory: 'coverage',
// normalizes browser name directories to lowercase without version
// ex: coverage/chrome/coverage.xml
subdirectory: browser => browser.name.toLowerCase().split(' ')[0],
filename: 'coverage.json',
},
text: '', // write to console
},
},
})
}