-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.config.js
95 lines (92 loc) · 2.1 KB
/
karma.config.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
const path = require("path");
const { config } = require("dotenv");
const outputPath = path.join(__dirname, "_karma_webpack_");
const webpack = require("webpack");
config()
const webpackConfig = {
mode: "development",
output: {
path: outputPath,
},
stats: {
modules: false,
colors: true,
},
module: {
rules: [
{
test: /\.ts?$/,
use: "ts-loader",
exclude: [/node_modules/],
},
],
},
externals: {
fs: "commonjs fs",
path: "commonjs path",
net: "commonjs net",
},
resolve: {
extensions: [".ts", ".js"],
modules: [path.join(__dirname, "node_modules")],
fallback: {
assert: false,
fs: false,
constants: false,
url: false,
path: require.resolve("path-browserify"),
os: require.resolve("os-browserify/browser"),
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("stream-browserify"),
},
},
plugins: [
new webpack.ProvidePlugin({
process: "process/browser",
path: "path-browserify",
os: "os-browserify/browser",
crypto: "crypto-browserify",
}),
new webpack.DefinePlugin({
"process.env": JSON.stringify(process.env),
}),
],
watch: false,
optimization: {
runtimeChunk: "single",
splitChunks: {
chunks: "all",
minSize: 0,
cacheGroups: {
commons: {
name: "commons",
chunks: "initial",
minChunks: 1,
},
},
},
},
};
module.exports = function (config) {
config.set({
frameworks: ["webpack", "jasmine"],
plugins: ["karma-webpack", "karma-jasmine", "karma-chrome-launcher"],
browsers: ["ChromeHeadless"],
basePath: "",
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
singleRun: true,
port: 9876,
concurrency: 10,
files: [
path.join(".", "karma.setup.js"),
path.join("test", "**/*.e2e-spec.ts"),
],
preprocessors: {
[path.join(".", "karma.setup.js")]: ["webpack"],
[path.join("test", "**/*.e2e-spec.ts")]: ["webpack"],
},
webpack: webpackConfig,
});
};