-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkarma.conf.js
104 lines (84 loc) · 2.06 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
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
104
'use strict';
const path = require('path');
const fs = require('fs');
const webpack = require('webpack');
let firebaseConfig = process.env.FIREBASE_CONFIG ||
fs.readFileSync('./firebase.config.local.json', {encoding: 'utf8'})
if (firebaseConfig === '') {
throw new Error('Failed to load Firebase config.')
}
const coverage = !!process.env['COVERAGE'];
if (coverage) {
console.log('Running tests with coverage!');
}
const reporters = ['mocha'];
if (coverage) {
reporters.push('karma-remap-istanbul')
}
const rules = [{
test: /\.ts$/,
loader: 'awesome-typescript-loader',
exclude: /node_modules/,
query: {
useBabel: true,
}
}];
if (coverage) {
rules.push({
enforce: 'post',
test: /\.(ts|js)$/,
loader: 'sourcemap-istanbul-instrumenter-loader',
exclude: [
/\.(spec|e2e|bundle)\.ts$/,
/node_modules/
],
query: {'force-sourcemap': true}
})
}
module.exports = function (karma) {
karma.set({
basePath: __dirname,
mime: {
'application/javascript': ['ts']
},
frameworks: ['jasmine'],
files: [{pattern: 'tests.bundle.ts', watched: false}],
preprocessors: {
'tests.bundle.ts': ['webpack']
},
reporters,
remapIstanbulReporter: {
reports: {
html: 'coverage',
lcovonly: 'coverage/lcov.info'
}
},
browsers: ['Chrome'],
colors: true,
autoWatch: true,
singleRun: false,
logLevel: karma.LOG_INFO,
webpack: {
devtool: 'inline-source-map',
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules,
},
plugins: [
new webpack.DefinePlugin({
firebaseConfig
}),
new webpack.ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
path.resolve(__dirname, './src')
),
new webpack.SourceMapDevToolPlugin({
filename: null, // if no value is provided the sourcemap is inlined
test: /\.(ts|js)($|\?)/i // process .js and .ts files only
})
]
}
})
};