-
Notifications
You must be signed in to change notification settings - Fork 27
/
test-web.js
executable file
·60 lines (55 loc) · 1.35 KB
/
test-web.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
#!/usr/bin/env node
/* eslint-env node */
/* eslint @typescript-eslint/no-var-requires:0 */
const esbuild = require("esbuild");
const path = require("path");
const { wasmTextPlugin } = require("./scripts/esbuild/wasm-text");
const Mocha = require("mocha");
let watch = false;
for (const arg of process.argv.slice(2)) {
switch (arg) {
case "--watch":
watch = true;
break;
}
}
function runTests() {
const mocha = new Mocha();
delete require.cache[path.join(__dirname, "build", "tests.js")];
mocha.addFile("build/tests.js");
mocha.run((failures) => (process.exitCode = failures ? 1 : 0));
}
let buildConfig = {
bundle: true,
logLevel: "warning",
entryPoints: [path.join(__dirname, "src", "web", "tests", "tests.node")],
target: "node17",
outdir: path.join(__dirname, "build"),
external: ["fs", "stream", "util", "events", "path"],
minify: false,
loader: {
".wasm": "binary",
".f": "text",
".fr": "text",
".fth": "text",
},
sourcemap: true,
plugins: [wasmTextPlugin({ debug: true })],
...(watch
? {
watch: {
async onRebuild(error) {
if (error) {
console.error(error);
} else {
runTests();
}
},
},
}
: {}),
};
esbuild.build(buildConfig).then(runTests, (e) => {
console.error(e);
process.exit(1);
});