This repository has been archived by the owner on Nov 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
117 lines (111 loc) · 3.63 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
105
106
107
108
109
110
111
112
113
114
115
116
117
/* eslint-env node */
"use strict";
const serveStatic = require("serve-static");
//
// karma-typescript-preprocessor does not support loading a tsconfig.json. There
// is an old issue saying it can but probably the TS API changed and it no
// longer works properly.
//
// karma-typescript-preprocessor2 has issues with supporting recent TS:
//
// - The gulp-typescript it uses will load a local typescript. This local
// typescript must be removed.
//
// - The gulp-typescript it uses does not support "extends".
//
function makeServeMiddleware(/* config */) {
const serve = serveStatic("./node_modules", {
index: false,
});
const baseURL = "/base/node_modules/";
return function handle(req, resp, next) {
if (req.url.lastIndexOf(baseURL, 0) === 0) {
req.url = req.url.slice(baseURL.length);
serve(req, resp, next);
}
else {
next();
}
};
}
module.exports = function configure(config) {
const coverage = !config.debug ? ["coverage"] : [];
config.set({
basePath: "",
frameworks: ["mocha", "chai"],
middleware: ["serve-node-modules"],
plugins: [
"karma-*", // This is the default, which we need to keep here.
{ "middleware:serve-node-modules": ["factory", makeServeMiddleware] },
],
client: {
mocha: {
grep: config.grep,
},
},
files: [
"node_modules/core-js/client/core.js",
//
// All the stuff after "zone" is needed to get Angular component tests to
// run. Note that we flatten this with a reduce at the end of the top
// array.
//
// And we map an array rather than rely on patterns because the matches
// from a pattern are ordered alphabetically but the order here matters
// (and is not alphabetical).
//
["zone", "long-stack-trace-zone", "proxy", "sync-test",
"async-test", "fake-async-test", "mocha-patch"].map(
x => `node_modules/zone.js/dist/${x}.js`),
"node_modules/wed/standalone/lib/external/classList.js",
"node_modules/wed/standalone/lib/wed/polyfills/contains.js",
"node_modules/wed/standalone/lib/wed/polyfills/matches.js",
"node_modules/wed/standalone/lib/wed/polyfills/innerHTML_for_XML.js",
"node_modules/systemjs/dist/system.src.js",
"test/karma-env.js",
"web/system.config.js",
"test/karma-main.js",
{ pattern: "test/**/*.ts", included: false },
{ pattern: "test/data/**", included: false },
{ pattern: "build/**/*.@(js|html|map|css)", included: false },
].reduce((acc, x) => acc.concat(x), []),
exclude: [],
preprocessors: {
"test/**/*.ts": ["typescript"],
"build/dev/lib/dashboard.js": coverage,
"build/dev/lib/dashboard/**/!(*.map).js": coverage,
},
typescriptPreprocessor: {
tsconfigPath: "./test/tsconfig.json",
compilerOptions: {
// eslint-disable-next-line global-require
typescript: require("typescript"),
sourceMap: false,
// We have to have them inline for the browser to find them.
inlineSourceMap: true,
inlineSources: true,
// noEmitOnError: false,
},
// transformPath: (path) => path.replace(/\.ts$/, ".js"),
},
reporters: ["mocha", "coverage", "karma-remap-istanbul"],
coverageReporter: {
type: "in-memory",
},
remapIstanbulReporter: {
remapOptions: {
// basePath: "src/dashboard/",
},
reports: {
html: "coverage/karma",
},
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ["ChromeHeadless"],
singleRun: false,
concurrency: Infinity,
});
};