-
Notifications
You must be signed in to change notification settings - Fork 8
/
karma.conf.js
78 lines (64 loc) · 2.11 KB
/
karma.conf.js
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
const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const baseConfig = require('./karma.base.conf.js');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const testEntryFile = 'spec/test.ts';
const configFile = 'tsconfig.json';
const coverage = process.argv.indexOf('--no-coverage') < 0;
console.log(`testPath: ${testEntryFile}`);
console.log(`configFile: ${configFile}`);
console.log(`coverage: ${coverage}`);
module.exports = function(config) {
baseConfig(config);
const reporters = ['progress', 'kjhtml', 'junit'];
const rules = [
{
test: /\.ts$/,
use: [
{
loader: 'ts-loader',
options: {
configFile,
},
},
],
},
];
const plugins = [new CircularDependencyPlugin({ exclude: /node_modules/ })];
if (coverage) {
reporters.push('coverage-istanbul');
rules.push({
test: /\.ts$/,
use: {
loader: '@jsdevtools/coverage-istanbul-loader',
options: {
esModules: true,
},
},
enforce: 'post',
include: path.resolve('main'),
exclude: /.spec.ts$/,
});
}
config.set({
frameworks: ['jasmine', 'webpack'],
reporters,
// list of files / patterns to load in the browser
files: [testEntryFile],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'**/*.ts': ['webpack'],
},
webpack: {
module: { rules },
resolve: {
extensions: ['.ts', '.js'],
plugins: [new TsconfigPathsPlugin({ configFile })], // Supports non standard base url for absolute imports
},
mode: 'development',
devtool: 'inline-source-map',
plugins,
},
});
};