1 | module.exports = function(config) {
|
2 | const karmaConfig = {
|
3 | frameworks: ["mocha", "chai", "chai-as-promised", "sinon", "karma-typescript"],
|
4 | mime: {
|
5 | 'text/x-typescript': ['ts','tsx']
|
6 | },
|
7 | client: {
|
8 | mocha: {
|
9 | opts: "./mocha.opts",
|
10 | },
|
11 | },
|
12 | files: [
|
13 | "./src/**/*.ts",
|
14 | "./test/**/*.ts",
|
15 | "./test/setup.js",
|
16 | {pattern: "./test/assets/**/*.*", watched: false, included: false, served: true},
|
17 | ],
|
18 | proxies: {
|
19 | "/assets/": "/base/test/assets/"
|
20 | },
|
21 | preprocessors: {
|
22 | "src/**/*.ts": ["karma-typescript"],
|
23 | "test/**/*.ts": ["karma-typescript"],
|
24 | },
|
25 | karmaTypescriptConfig: {
|
26 | tsconfig: "./tsconfig.test.json",
|
27 | reports: {
|
28 | html: {
|
29 | "directory": "coverage",
|
30 | "subdirectory": "./"
|
31 | },
|
32 | lcovonly: {
|
33 | "directory": "coverage",
|
34 | "filename": "lcov.info",
|
35 | "subdirectory": "."
|
36 | },
|
37 | },
|
38 | coverageOptions: {
|
39 | instrumentation: true,
|
40 | exclude: /test/i,
|
41 | },
|
42 | bundlerOptions: {
|
43 | transforms: [
|
44 | require("karma-typescript-es6-transform")()
|
45 | ]
|
46 | }
|
47 | },
|
48 | browsers: [],
|
49 | customLaunchers: {
|
50 | CustomChromeHeadless: {
|
51 | base: "ChromeHeadless",
|
52 | flags: ["--window-size=400,300", "--no-sandbox", "--disable-setuid-sandbox"],
|
53 | },
|
54 | },
|
55 | reporters: ["mocha"],
|
56 | };
|
57 |
|
58 | karmaConfig.browsers.push(config.chrome ? "Chrome" : "CustomChromeHeadless");
|
59 |
|
60 | if (config.coverage) {
|
61 | karmaConfig.reporters.push("karma-typescript");
|
62 | karmaConfig.singleRun = true;
|
63 | }
|
64 |
|
65 | config.set(karmaConfig);
|
66 | };
|