@bsb/tests 9.5.7 → 9.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/bsb-tests.cjs +23 -4
- package/package.json +2 -2
package/bin/bsb-tests.cjs
CHANGED
|
@@ -47,6 +47,18 @@ const findFiles = (dir, filename, results = []) => {
|
|
|
47
47
|
|
|
48
48
|
const readJson = (filePath) => JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
49
49
|
|
|
50
|
+
const resolvePackageBin = (packageName, binName) => {
|
|
51
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`);
|
|
52
|
+
const packageJson = readJson(packageJsonPath);
|
|
53
|
+
const binPath = typeof packageJson.bin === "string"
|
|
54
|
+
? packageJson.bin
|
|
55
|
+
: packageJson.bin?.[binName];
|
|
56
|
+
if (!binPath) {
|
|
57
|
+
throw new Error(`Package ${packageName} does not declare bin ${binName}`);
|
|
58
|
+
}
|
|
59
|
+
return path.resolve(path.dirname(packageJsonPath), binPath);
|
|
60
|
+
};
|
|
61
|
+
|
|
50
62
|
const resolvePluginModule = (pluginRoot, pluginPath, useTs) => {
|
|
51
63
|
const base = path.resolve(pluginRoot, pluginPath || "");
|
|
52
64
|
if (useTs) {
|
|
@@ -66,9 +78,16 @@ const hasBuiltPluginModule = (pluginRoot, pluginPath) => {
|
|
|
66
78
|
|
|
67
79
|
const resolveLocalBaseEntry = (repoRoot, useTs) => {
|
|
68
80
|
const nestedBaseRoot = path.join(repoRoot, "nodejs");
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
let baseRoot = null;
|
|
82
|
+
if (fs.existsSync(path.join(nestedBaseRoot, "package.json"))) {
|
|
83
|
+
baseRoot = nestedBaseRoot;
|
|
84
|
+
} else {
|
|
85
|
+
const packageJsonPath = path.join(repoRoot, "package.json");
|
|
86
|
+
if (fs.existsSync(packageJsonPath) && readJson(packageJsonPath).name === "@bsb/base") {
|
|
87
|
+
baseRoot = repoRoot;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (!baseRoot) return null;
|
|
72
91
|
const entryTs = path.join(baseRoot, "src", "index.ts");
|
|
73
92
|
const entryJs = path.join(baseRoot, "lib", "index.js");
|
|
74
93
|
if (useTs && fs.existsSync(entryTs)) return entryTs;
|
|
@@ -164,7 +183,7 @@ if (filtered.length === 0) {
|
|
|
164
183
|
}
|
|
165
184
|
|
|
166
185
|
const repoRoot = cwd;
|
|
167
|
-
const mochaBin =
|
|
186
|
+
const mochaBin = resolvePackageBin("mocha", "mocha");
|
|
168
187
|
const setupHook = path.join(__dirname, "..", "lib", "runner", "setup.js");
|
|
169
188
|
const pluginEventsRunner = path.join(__dirname, "..", "lib", "runner", "plugin-events.js");
|
|
170
189
|
const pluginObservableRunner = path.join(__dirname, "..", "lib", "runner", "plugin-observable.js");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsb/tests",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.8",
|
|
4
4
|
"description": "Shared test suites for BSB Node.js core and plugins",
|
|
5
5
|
"license": "(AGPL-3.0-only OR Commercial)",
|
|
6
6
|
"author": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@bsb/base": "^9.0.0",
|
|
32
|
-
"mocha": "^
|
|
32
|
+
"mocha": "^11.7.6",
|
|
33
33
|
"nyc": "^17.1.0",
|
|
34
34
|
"ts-node": "^10.9.2"
|
|
35
35
|
},
|