-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.mocha.js
54 lines (45 loc) · 1.43 KB
/
webpack.mocha.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
const buildConfig = require("./webpack.config");
const path = require("path");
const ROOT = __dirname;
const WebpackShellPlugin = require("webpack-shell-plugin-next");
const glob = require("glob");
const IN_WATCH_MODE = process.argv.some(arg => arg === "--watch" || arg === "-w");
const config = {
entry: glob.sync("./test/**/*.test.ts"),
mode: "development",
context: ROOT,
target: "web",
devtool: "source-map",
output: {
filename: "[name].js",
path: path.resolve(ROOT, "testbuild")
},
resolve: buildConfig.resolve,
module: {
rules: [
{
test: /\.tsx?$/,
use: {
loader: "ts-loader",
options: {
// @todo can not be taken from webpack.config.js
configFile: path.resolve(ROOT, "./test/tsconfig.json")
}
}
}
]
},
plugins: [
new WebpackShellPlugin({
// --exit is required until a fix for non-closed jsdom is found:
// `dom.window.close()`
dev: false,
swallowError: IN_WATCH_MODE,
onBuildExit: {
// eslint-disable-next-line max-len
scripts: ["mocha --exit --require source-map-support/register --require ./test/mocha.setup.js testbuild/main.js"]
}
})
]
};
module.exports = config;