forked from aurelia/ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.ts
89 lines (82 loc) · 2.23 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
import * as karma from 'karma';
import * as webpack from 'webpack';
export interface KarmaConfig extends karma.Config, KarmaConfigOptions {
package?: string;
set(config: KarmaConfigOptions): void;
}
export interface KarmaConfigOptions extends karma.ConfigOptions {
webpack: webpack.Configuration;
coverageIstanbulReporter: any;
webpackServer: any;
}
const defaultOptions: KarmaConfigOptions = {
basePath: './',
frameworks: ['jasmine'],
files: ['test/setup.ts'],
preprocessors: {
'test/setup.ts': ['webpack', 'sourcemap']
},
webpack: {
mode: 'development',
resolve: {
extensions: ['.ts', '.js'],
modules: ['src', 'node_modules']
},
devtool: 'cheap-module-eval-source-map',
module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: {
configFile: 'tsconfig-test.json',
transpileOnly: true
}
},
{
enforce: 'post',
exclude: /(node_modules|\.spec\.ts$)/,
loader: 'istanbul-instrumenter-loader',
options: { esModules: true },
test: /src[\/\\].+\.ts$/
}
]
}
},
mime: {
'text/x-typescript': ['ts']
},
reporters: ['mocha', 'progress', 'coverage-istanbul'],
coverageIstanbulReporter: {
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
webpackServer: { noInfo: true },
port: 9876,
colors: true,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
};
export function configureKarma(
config: KarmaConfig,
configure?: (options: KarmaConfigOptions) => void
): void {
const options = { ...defaultOptions };
// config.package contains the value passed in via "karma start --package=..."
// only need to set this when running from the root
if (config.package) {
options.basePath = `./packages/${config.package}`;
}
options.logLevel = config.LOG_INFO;
if (typeof configure === 'function') {
configure(options);
}
config.set(options);
}
export default (config: KarmaConfig): void => {
configureKarma(config, (options: KarmaConfigOptions) => {
(options.webpack.module as any).rules[0].options.configFile = 'tsconfig.json';
});
};