-
Notifications
You must be signed in to change notification settings - Fork 57
/
karma.conf.cjs
89 lines (71 loc) · 2.23 KB
/
karma.conf.cjs
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
const webpackConfig = require("./webpack.config.cjs");
const CI = !!process.env.CI;
delete webpackConfig.entry;
delete webpackConfig.output;
webpackConfig.mode = process.env.BUNDLE === "production" ? "production" : "development";
webpackConfig.module.rules.push({
test: /\.(png|jpg)$/,
use: "arraybuffer-loader"
});
// BEGIN typescript support
webpackConfig.module.rules.unshift({
test: /\.js$/,
use: [{
loader: "babel-loader",
options: {
"presets": [
["@babel/preset-env", {
"useBuiltIns": false,
"targets": {
"firefox": "70"
}
}]
],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread"
]
}
}]
});
const tsRule = webpackConfig.module.rules.find(rule => rule.test && /\.ts/.test(rule.test.toString()));
tsRule.use.options.configFile = tsRule.use.options.configFile.replace("tsconfig.web.json", "tsconfig.web.test.json");
// END typescript support
module.exports = config => config.set({
basePath: __dirname,
browsers: CI ? ["ChromeHeadless", "FirefoxHeadless"] : ["ChromeHeadless"],
captureTimeout: 60000,
colors: true,
// coverageReporter: {
// dir: "build/coverage/",
// reporters: [
// { type: "html" },
// { type: "text" },
// { type: "text-summary" }
// ]
// },
exclude: [],
files: [
{ pattern: "source/index.web.ts" },
{ pattern: "test/web/index.js" },
{ pattern: "test/web/**/*.spec.js" }
],
frameworks: ["mocha", "sinon", "webpack"],
// logLevel: config.LOG_DEBUG,
plugins: [
require("karma-webpack"),
require("karma-chrome-launcher"),
require("karma-firefox-launcher"),
require("karma-mocha"),
require("karma-sinon"),
require("karma-spec-reporter")
],
preprocessors: {
"*.ts": ["webpack"],
"test/web/index.js": ["webpack"],
"test/web/**/*.spec.js": ["webpack"]
},
reporters: ["spec", "progress"],
singleRun: true,
webpack: webpackConfig
});