-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.karma.js
41 lines (39 loc) · 1.45 KB
/
webpack.config.karma.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
const webpackConfig = require('./webpack.config.js');
const StringReplacePlugin = require("string-replace-webpack-plugin");
// These modifications are required to have proper coverage with karma-coverage-istanbul-reporter.
webpackConfig.devtool = "inline-source-map";
webpackConfig.module.rules.find(rule => rule.loader === "ts-loader").options.compilerOptions = {
"inlineSourceMap": true
};
webpackConfig.module.rules.push({
enforce: "post",
test: /\.ts$/,
loader: 'istanbul-instrumenter-loader',
exclude: [
'node_modules',
/\.spec\.ts$/
]
});
/*
* Ensures that TypeScript extends is not counted twice for the "branches" coverage summary.
* Since `super()` outputs `_super.call() || this`, it counts as two branches in the coverage.
* This gives a cleaner coverage output.
* See issue here for more details: https://github.com/Microsoft/TypeScript/issues/13029
*/
const ignoreNonRequiredBranchForIstanbulRule = {
enforce: "pre",
test:/\.ts/,
loader: StringReplacePlugin.replace({
replacements: [{
pattern:/(super\([,\.\w\s]+\))[;]??/i,
replacement: function(match, part1, offset, string) {
return `${part1} /* istanbul ignore next: TypeScript extends */;`;
}
}]
})
};
webpackConfig.module.rules.push(ignoreNonRequiredBranchForIstanbulRule)
webpackConfig.externals.push({
"coveo-search-ui-tests": "CoveoJsSearchTests"
});
module.exports = webpackConfig;