/
karma.conf.ts
103 lines (87 loc) · 2.27 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import tsEs6Config from 'karma-typescript-es6-transform';
import type { Config, ConfigOptions } from 'karma';
import type { KarmaTypescriptConfig } from 'karma-typescript';
type Extendable<T> = T & { [key: string]: unknown };
export default ( config: Config ): void => {
// types provided by @types/karma are incomplete,
// so this is needed to get TS to compile
const conf: Extendable<Partial<ConfigOptions> & {
karmaTypescriptConfig: KarmaTypescriptConfig,
client: Extendable<ConfigOptions['client']>,
}> = {
plugins: [
'karma-typescript',
'karma-jasmine',
'karma-chrome-launcher',
'karma-spec-reporter',
],
concurrency: 1,
failOnEmptyTestSuite: false,
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: __dirname,
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'karma-typescript'],
// list of files to load in the browser
files: [
'packages/*/src/**/*.ts',
],
exclude: [
'packages/hlsl-loader/**',
'packages/devtools-extension/**',
'packages/ecs/src/env.d.ts',
'packages/devtools/src/env.d.ts',
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'**/*.ts': ['karma-typescript'],
},
karmaTypescriptConfig: {
include: [
'packages/*/src',
],
exclude: [
'packages/hlsl-loader',
'packages/devtools-extension',
'packages/ecs/src/env.d.ts',
'packages/devtools/src/env.d.ts',
],
bundlerOptions: {
constants: {
__DEV_BUILD__: true,
__VERSION__: '"TESTBUILD"',
},
transforms: [
tsEs6Config(),
],
},
compilerOptions: {
downlevelIteration: true,
},
reports: {
html: '_coverage',
'text-summary': null,
},
},
reporters: ['karma-typescript', 'spec'],
specReporter: {
suppressSkipped: false,
prefixes: {
success: ' OK: ',
failure: 'FAIL: ',
skipped: 'SKIP: ',
},
},
client: {
jasmine: {
random: false,
},
captureConsole: false,
},
browsers: ['ChromeHeadless'],
};
config.set( conf as ConfigOptions );
};