-
Notifications
You must be signed in to change notification settings - Fork 304
/
.mocharc.cjs
68 lines (54 loc) · 2.01 KB
/
.mocharc.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
const yargs = require("yargs").argv;
const resolve = require("path").resolve;
const join = require("path").join;
const fs = require("fs");
const prettyjson = require("prettyjson");
function getAllPackageFolderNames() {
const root = resolve("./packages");
return fs.readdirSync(root).filter(dirName => {
const stat = fs.statSync(join(root, dirName));
return stat && stat.isDirectory();
});
}
const basePath = "./build/testing/test/";
let paths = [];
// handle package specific config
if (yargs.packages || yargs.p) {
const packageNames = (yargs.packages || yargs.p).split(",").map(s => s.trim().toLowerCase());
const processingPackages = [];
for (let i = 0; i < packageNames.length; i++) {
// see of we have any package entries and pass them along as-is
const found = getAllPackageFolderNames().filter(p => {
return ((typeof p === "string" && p === packageNames[i]) || (p.name === packageNames[i]));
});
processingPackages.push(...found);
}
if (yargs.single || yargs.s) {
// and only a single set of tests
paths.push(resolve(`${basePath}${processingPackages[0]}/`, (yargs.single || yargs.s) + ".js"));
} else {
paths.push(...processingPackages.map(p => `${basePath}${p}/**/*.js`));
}
} else {
paths.push(`${basePath}**/*.js`);
}
const reporter = yargs.verbose ? "spec" : "dot";
const retries = yargs.noretries ? "0" : "2";
const config = {
package: "./package.json",
reporter,
slow: 2000,
timeout: 40000,
ui: "bdd",
retries,
"node-option": [`experimental-loader=${process.platform === "win32" ? "file://" : ""}${resolve("./build/testing/tools/local-module-resolver/esm-test.js")}`],
spec: paths,
require: `${basePath}mocha-root-hooks.js`,
};
console.info(`*****************************`);
console.info("pnp generated mocha config:");
console.info(prettyjson.render(config, null, 4, {
noColor: true
}));
console.info(`*****************************`);
module.exports = config;