@aljazmc/testero 0.5.0 → 0.5.1
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/main.js +33 -15
- package/package.json +2 -2
package/bin/main.js
CHANGED
|
@@ -111,7 +111,7 @@ import {
|
|
|
111
111
|
statSync,
|
|
112
112
|
writeFileSync
|
|
113
113
|
} from "node:fs";
|
|
114
|
-
import { join } from "node:path";
|
|
114
|
+
import { join, relative, resolve, sep } from "node:path";
|
|
115
115
|
import { pathToFileURL } from "node:url";
|
|
116
116
|
var Config;
|
|
117
117
|
var init_config = __esm({
|
|
@@ -233,6 +233,24 @@ ${items.map((item) => `${inner}${item},
|
|
|
233
233
|
merged[key] = _Config.merge(base[key], value);
|
|
234
234
|
return merged;
|
|
235
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Whether a file, relative to the root, is one of some paths or in one
|
|
238
|
+
* of them, like the paths a tool is given on its command line, relative
|
|
239
|
+
* to `base`. Without paths, every file is. A path that does not exist is
|
|
240
|
+
* an error.
|
|
241
|
+
*/
|
|
242
|
+
within(paths, base = process.cwd()) {
|
|
243
|
+
if (paths.length === 0) return () => true;
|
|
244
|
+
const relatives = paths.map((path) => {
|
|
245
|
+
const absolute = resolve(base, path);
|
|
246
|
+
if (!existsSync(absolute))
|
|
247
|
+
throw new Error(`${path}: no such file or folder.`);
|
|
248
|
+
return relative(this.root, absolute).split(sep).join("/");
|
|
249
|
+
});
|
|
250
|
+
return (file) => relatives.some(
|
|
251
|
+
(path) => path === "" || file === path || file.startsWith(`${path}/`)
|
|
252
|
+
);
|
|
253
|
+
}
|
|
236
254
|
/**
|
|
237
255
|
* The files that are not ignored, relative to the root. Symlinks are
|
|
238
256
|
* followed, a folder by every path to it, but not into a folder it is in,
|
|
@@ -1151,7 +1169,7 @@ var init_globals = __esm({
|
|
|
1151
1169
|
// packages/testero/src/transformer.ts
|
|
1152
1170
|
import { mkdtempSync, readFileSync as readFileSync2, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
1153
1171
|
import { tmpdir } from "node:os";
|
|
1154
|
-
import { dirname, extname, join as join2, resolve, sep } from "node:path";
|
|
1172
|
+
import { dirname, extname, join as join2, resolve as resolve2, sep as sep2 } from "node:path";
|
|
1155
1173
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
1156
1174
|
import { build } from "esbuild";
|
|
1157
1175
|
var Transformer;
|
|
@@ -1221,7 +1239,7 @@ var init_transformer = __esm({
|
|
|
1221
1239
|
...this.#options(file),
|
|
1222
1240
|
metafile: true
|
|
1223
1241
|
});
|
|
1224
|
-
return Object.keys(metafile.inputs).filter((input) => !/^[\w-]+:/.test(input)).map((input) =>
|
|
1242
|
+
return Object.keys(metafile.inputs).filter((input) => !/^[\w-]+:/.test(input)).map((input) => resolve2(input)).filter((input) => input !== this.#globals);
|
|
1225
1243
|
}
|
|
1226
1244
|
/** What compiling and listing the inputs share. */
|
|
1227
1245
|
#options(file) {
|
|
@@ -1329,7 +1347,7 @@ import __testero from ${meta};
|
|
|
1329
1347
|
return `${source.slice(0, start)}var __testero = require(${meta}).default;${source.slice(start)}`;
|
|
1330
1348
|
}
|
|
1331
1349
|
static #installed(path) {
|
|
1332
|
-
return path.split(
|
|
1350
|
+
return path.split(sep2).includes("node_modules");
|
|
1333
1351
|
}
|
|
1334
1352
|
};
|
|
1335
1353
|
}
|
|
@@ -1338,7 +1356,7 @@ import __testero from ${meta};
|
|
|
1338
1356
|
// packages/testero/src/coverage.ts
|
|
1339
1357
|
import { readFileSync as readFileSync3 } from "node:fs";
|
|
1340
1358
|
import { Session } from "node:inspector/promises";
|
|
1341
|
-
import { dirname as dirname2, join as join3, relative, resolve as
|
|
1359
|
+
import { dirname as dirname2, join as join3, relative as relative2, resolve as resolve3 } from "node:path";
|
|
1342
1360
|
import { fileURLToPath } from "node:url";
|
|
1343
1361
|
import { transform } from "esbuild";
|
|
1344
1362
|
var Coverage;
|
|
@@ -1434,7 +1452,7 @@ var init_coverage = __esm({
|
|
|
1434
1452
|
if (inline === void 0) return;
|
|
1435
1453
|
const map = JSON.parse(Buffer.from(inline, "base64").toString());
|
|
1436
1454
|
const sources = map.sources.map((source) => {
|
|
1437
|
-
const file =
|
|
1455
|
+
const file = relative2(this.#root, resolve3(directory, source)).split("\\").join("/");
|
|
1438
1456
|
if (!this.#tracks(file)) return void 0;
|
|
1439
1457
|
let coverage = files.get(file);
|
|
1440
1458
|
if (!coverage) {
|
|
@@ -2457,7 +2475,7 @@ Expected ${this.#expected} assertion${this.#expected === 1 ? "" : "s"} to be cal
|
|
|
2457
2475
|
|
|
2458
2476
|
// packages/testero/src/reporter.ts
|
|
2459
2477
|
import { existsSync as existsSync2, readFileSync as readFileSync4 } from "node:fs";
|
|
2460
|
-
import { dirname as dirname3, isAbsolute, relative as
|
|
2478
|
+
import { dirname as dirname3, isAbsolute, relative as relative3 } from "node:path";
|
|
2461
2479
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
2462
2480
|
var Reporter;
|
|
2463
2481
|
var init_reporter = __esm({
|
|
@@ -2722,7 +2740,7 @@ ${failed ? "\n" : ""}`);
|
|
|
2722
2740
|
return out.join("\n");
|
|
2723
2741
|
}
|
|
2724
2742
|
#path(file) {
|
|
2725
|
-
const path =
|
|
2743
|
+
const path = relative3(this.#root, file);
|
|
2726
2744
|
return path.startsWith("..") ? file : path;
|
|
2727
2745
|
}
|
|
2728
2746
|
#paint(text, ...styles) {
|
|
@@ -2871,11 +2889,11 @@ var init_runner = __esm({
|
|
|
2871
2889
|
/** Runs a body as a promise, with a `done` callback when it takes one. */
|
|
2872
2890
|
static #invoke(body) {
|
|
2873
2891
|
if (body.length === 0)
|
|
2874
|
-
return new Promise((
|
|
2892
|
+
return new Promise((resolve4) => resolve4(body(() => {
|
|
2875
2893
|
})));
|
|
2876
|
-
return new Promise((
|
|
2894
|
+
return new Promise((resolve4, reject) => {
|
|
2877
2895
|
body(
|
|
2878
|
-
(error) => error === void 0 ?
|
|
2896
|
+
(error) => error === void 0 ? resolve4(void 0) : reject(error)
|
|
2879
2897
|
);
|
|
2880
2898
|
});
|
|
2881
2899
|
}
|
|
@@ -3356,7 +3374,7 @@ var init_watcher = __esm({
|
|
|
3356
3374
|
var index_exports = {};
|
|
3357
3375
|
import { spawn } from "node:child_process";
|
|
3358
3376
|
import { watch } from "node:fs";
|
|
3359
|
-
import { join as join5, relative as
|
|
3377
|
+
import { join as join5, relative as relative4, sep as sep3 } from "node:path";
|
|
3360
3378
|
var init_index = __esm({
|
|
3361
3379
|
async "packages/testero/src/index.ts"() {
|
|
3362
3380
|
"use strict";
|
|
@@ -3382,7 +3400,7 @@ var init_index = __esm({
|
|
|
3382
3400
|
const transformer = new Transformer();
|
|
3383
3401
|
const dependencies = new Dependencies(
|
|
3384
3402
|
async (file) => (await transformer.inputs(join5(config.root, file))).map(
|
|
3385
|
-
(input) =>
|
|
3403
|
+
(input) => relative4(config.root, input).split(sep3).join("/")
|
|
3386
3404
|
)
|
|
3387
3405
|
);
|
|
3388
3406
|
const coverage = new Pattern(`/${options.coverageDirectory}`);
|
|
@@ -3401,7 +3419,7 @@ var init_index = __esm({
|
|
|
3401
3419
|
);
|
|
3402
3420
|
return {
|
|
3403
3421
|
done: new Promise(
|
|
3404
|
-
(
|
|
3422
|
+
(resolve4) => child.on("close", resolve4).on("error", resolve4)
|
|
3405
3423
|
),
|
|
3406
3424
|
stop: /* @__PURE__ */ __name(() => child.kill(), "stop")
|
|
3407
3425
|
};
|
|
@@ -3412,7 +3430,7 @@ var init_index = __esm({
|
|
|
3412
3430
|
config.root,
|
|
3413
3431
|
{ recursive: true },
|
|
3414
3432
|
(_, name) => {
|
|
3415
|
-
if (name) listener(name.split(
|
|
3433
|
+
if (name) listener(name.split(sep3).join("/"));
|
|
3416
3434
|
}
|
|
3417
3435
|
);
|
|
3418
3436
|
return () => watching.close();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aljazmc/testero",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "A simple, Jest-like test runner for JavaScript, TypeScript and JSX, compiling tests with esbuild. Easy to understand, easy to customize and easy to extend.",
|
|
5
5
|
"author": "aljazmc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@types/node": "^26.6.6"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@aljazmc/config": "^0.3.
|
|
41
|
+
"@aljazmc/config": "^0.3.3",
|
|
42
42
|
"esbuild": "0.28.2"
|
|
43
43
|
}
|
|
44
44
|
}
|