vitest-bats 0.0.3 → 0.0.5
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/bats-executor.js +1 -2
- package/bats-generator.js +1 -2
- package/coverage-reporter.js +1 -2
- package/index.d.ts +0 -16
- package/index.js +2 -2
- package/matchers.js +1 -2
- package/package.json +3 -3
- package/plugin.js +1 -2
- package/runtime.d.ts +0 -2
- package/runtime.js +1 -2
- package/schema.js +1 -2
- package/setup.js +2 -3
- package/tsdoc-metadata.json +1 -1
package/bats-executor.js
CHANGED
|
@@ -3,7 +3,7 @@ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node
|
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join, resolve } from "node:path";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/bats-executor.ts
|
|
7
7
|
let cleanupRegistered = false;
|
|
8
8
|
let batsFileDirCache = null;
|
|
9
9
|
function getBatsFileDir() {
|
|
@@ -99,5 +99,4 @@ function executeBats(opts) {
|
|
|
99
99
|
return parseExecutionResult(opts.recorderDir);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
//#endregion
|
|
103
102
|
export { executeBats, parseExecutionResult };
|
package/bats-generator.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dirname } from "node:path";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/bats-generator.ts
|
|
4
4
|
function shellQuote(s) {
|
|
5
5
|
return `"${s.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
|
|
6
6
|
}
|
|
@@ -110,5 +110,4 @@ function generateBatsFile(input) {
|
|
|
110
110
|
return lines.join("\n");
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
//#endregion
|
|
114
113
|
export { generateBatsFile };
|
package/coverage-reporter.js
CHANGED
|
@@ -2,7 +2,7 @@ import { existsSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs
|
|
|
2
2
|
import { basename, resolve } from "node:path";
|
|
3
3
|
import { XMLParser } from "fast-xml-parser";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/coverage-reporter.ts
|
|
6
6
|
/**
|
|
7
7
|
* Vitest coverage reporter that merges kcov's shell-script coverage into the v8
|
|
8
8
|
* Istanbul CoverageMap, with synthetic branch/function entries so threshold checks
|
|
@@ -315,5 +315,4 @@ var BatsCoverageReporter = class {
|
|
|
315
315
|
}
|
|
316
316
|
};
|
|
317
317
|
|
|
318
|
-
//#endregion
|
|
319
318
|
export { BatsCoverageReporter };
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Plugin } from "vitest/config";
|
|
2
2
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
3
|
-
//#region src/vitest-kcov-types.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* TypeScript module augmentation for Vitest coverage options.
|
|
6
5
|
*
|
|
@@ -274,8 +273,6 @@ declare module "vitest/node" {
|
|
|
274
273
|
kcov?: KcovOptions;
|
|
275
274
|
}
|
|
276
275
|
}
|
|
277
|
-
//#endregion
|
|
278
|
-
//#region src/runtime.d.ts
|
|
279
276
|
/**
|
|
280
277
|
* A single recorded invocation of a mocked command, captured back to the test as
|
|
281
278
|
* part of {@link BatsResult.calls}.
|
|
@@ -354,8 +351,6 @@ export declare class ScriptBuilder {
|
|
|
354
351
|
reset(): void;
|
|
355
352
|
private execute;
|
|
356
353
|
}
|
|
357
|
-
//#endregion
|
|
358
|
-
//#region src/bats-executor.d.ts
|
|
359
354
|
/**
|
|
360
355
|
* Options for {@link executeBats}.
|
|
361
356
|
* @internal
|
|
@@ -376,8 +371,6 @@ export declare function parseExecutionResult(recorderDir: string): BatsResultDat
|
|
|
376
371
|
* @internal
|
|
377
372
|
*/
|
|
378
373
|
export declare function executeBats(opts: ExecuteOptions): BatsResultData;
|
|
379
|
-
//#endregion
|
|
380
|
-
//#region src/bats-generator.d.ts
|
|
381
374
|
/**
|
|
382
375
|
* Resolved paths to the `bats` binary and the `bats-support` library, detected by
|
|
383
376
|
* `BatsPlugin` and threaded through to {@link generateBatsFile}.
|
|
@@ -436,8 +429,6 @@ interface GenerateInput {
|
|
|
436
429
|
* @internal
|
|
437
430
|
*/
|
|
438
431
|
export declare function generateBatsFile(input: GenerateInput): string;
|
|
439
|
-
//#endregion
|
|
440
|
-
//#region src/coverage-reporter.d.ts
|
|
441
432
|
/**
|
|
442
433
|
* Coverage thresholds applied to the merged v8/kcov CoverageMap.
|
|
443
434
|
* @public
|
|
@@ -486,8 +477,6 @@ export declare class BatsCoverageReporter {
|
|
|
486
477
|
private findCoberturaFiles;
|
|
487
478
|
private parseCoberturaToIstanbul;
|
|
488
479
|
}
|
|
489
|
-
//#endregion
|
|
490
|
-
//#region src/matchers.d.ts
|
|
491
480
|
/**
|
|
492
481
|
* The `{ pass, message }` shape expected by Vitest's `expect.extend`.
|
|
493
482
|
* @public
|
|
@@ -591,8 +580,6 @@ declare module "vitest" {
|
|
|
591
580
|
}[]): void;
|
|
592
581
|
}
|
|
593
582
|
}
|
|
594
|
-
//#endregion
|
|
595
|
-
//#region src/plugin.d.ts
|
|
596
583
|
/**
|
|
597
584
|
* Options for {@link BatsPlugin}.
|
|
598
585
|
* @public
|
|
@@ -624,8 +611,6 @@ interface BatsPluginOptions {
|
|
|
624
611
|
* @public
|
|
625
612
|
*/
|
|
626
613
|
export declare function BatsPlugin(options?: BatsPluginOptions): Plugin;
|
|
627
|
-
//#endregion
|
|
628
|
-
//#region src/schema.d.ts
|
|
629
614
|
/**
|
|
630
615
|
* Result of {@link validate}: either success, or failure with human-readable issue
|
|
631
616
|
* strings, used internally by the `toMatchSchema`/`toMatchJsonSchema` matchers.
|
|
@@ -650,6 +635,5 @@ export declare function isStandardSchema(schema: unknown): schema is StandardSch
|
|
|
650
635
|
* @internal
|
|
651
636
|
*/
|
|
652
637
|
export declare function validate(schema: unknown, value: unknown): ValidationResult;
|
|
653
|
-
//#endregion
|
|
654
638
|
export type { BatsDeps, BatsPluginOptions, BatsResultData, CoverageThresholds, ExecuteOptions, GenerateInput, KcovConfig, KcovOptions, KcovThresholds, LinkFormat, LogLevel, MatcherResult, MockCall, RunMode, StubSpec, ValidationResult };
|
|
655
639
|
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { executeBats, parseExecutionResult } from "./bats-executor.js";
|
|
2
2
|
import { generateBatsFile } from "./bats-generator.js";
|
|
3
3
|
import { BatsCoverageReporter } from "./coverage-reporter.js";
|
|
4
|
-
import { BatsResult, ScriptBuilder, resetAllBuilders } from "./runtime.js";
|
|
5
|
-
import { isStandardSchema, validate } from "./schema.js";
|
|
6
4
|
import { batsMatchers } from "./matchers.js";
|
|
7
5
|
import { BatsPlugin } from "./plugin.js";
|
|
6
|
+
import { BatsResult, ScriptBuilder, resetAllBuilders } from "./runtime.js";
|
|
7
|
+
import { isStandardSchema, validate } from "./schema.js";
|
|
8
8
|
|
|
9
9
|
export { BatsCoverageReporter, BatsPlugin, BatsResult, ScriptBuilder, batsMatchers, executeBats, generateBatsFile, isStandardSchema, parseExecutionResult, resetAllBuilders, validate };
|
package/matchers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BATS_RESULT_BRAND } from "./runtime.js";
|
|
2
2
|
import { validate } from "./schema.js";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/matchers.ts
|
|
5
5
|
function ensureBatsResult(received) {
|
|
6
6
|
if (received !== null && typeof received === "object" && received[BATS_RESULT_BRAND] === true) return received;
|
|
7
7
|
throw new Error("vitest-bats matcher: expected received value to be a BatsResult (the value returned by hello.run() or hello.exec())");
|
|
@@ -306,5 +306,4 @@ const batsMatchers = {
|
|
|
306
306
|
}
|
|
307
307
|
};
|
|
308
308
|
|
|
309
|
-
//#endregion
|
|
310
309
|
export { batsMatchers };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest-bats",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Test bash scripts with kcov coverage directly in Vitest",
|
|
6
6
|
"keywords": [
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"@standard-schema/spec": "^1.1.0",
|
|
52
52
|
"ajv": "^8.20.0",
|
|
53
53
|
"ajv-formats": "^3.0.1",
|
|
54
|
-
"fast-xml-parser": "^5.
|
|
55
|
-
"minimatch": "^
|
|
54
|
+
"fast-xml-parser": "^5.12.0",
|
|
55
|
+
"minimatch": "^11.0.6"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"vitest": "^5.0.0"
|
package/plugin.js
CHANGED
|
@@ -3,7 +3,7 @@ import { existsSync, mkdirSync, realpathSync, writeFileSync } from "node:fs";
|
|
|
3
3
|
import { type } from "node:os";
|
|
4
4
|
import { basename, dirname, resolve } from "node:path";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/plugin.ts
|
|
7
7
|
function getCommandPath(command) {
|
|
8
8
|
try {
|
|
9
9
|
const result = execSync(`command -v ${command}`, {
|
|
@@ -204,5 +204,4 @@ function BatsPlugin(options = {}) {
|
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
//#endregion
|
|
208
207
|
export { BatsPlugin };
|
package/runtime.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* A single recorded invocation of a mocked command, captured back to the test as
|
|
4
3
|
* part of {@link BatsResult.calls}.
|
|
@@ -77,5 +76,4 @@ export declare class ScriptBuilder {
|
|
|
77
76
|
reset(): void;
|
|
78
77
|
private execute;
|
|
79
78
|
}
|
|
80
|
-
//#endregion
|
|
81
79
|
//# sourceMappingURL=runtime.d.ts.map
|
package/runtime.js
CHANGED
|
@@ -4,7 +4,7 @@ import { mkdirSync } from "node:fs";
|
|
|
4
4
|
import { tmpdir } from "node:os";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// src/runtime.ts
|
|
8
8
|
/**
|
|
9
9
|
* Symbol brand identifying a BatsResult instance. Used by matchers to
|
|
10
10
|
* detect BatsResult inputs in a way that survives:
|
|
@@ -168,5 +168,4 @@ var ScriptBuilder = class {
|
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
-
//#endregion
|
|
172
171
|
export { BATS_RESULT_BRAND, BatsResult, ScriptBuilder, resetAllBuilders };
|
package/schema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Ajv } from "ajv";
|
|
2
2
|
import addFormatsModule from "ajv-formats";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/schema.ts
|
|
5
5
|
const addFormats = addFormatsModule.default;
|
|
6
6
|
let ajvSingleton = null;
|
|
7
7
|
function getAjv() {
|
|
@@ -71,5 +71,4 @@ function validate(schema, value) {
|
|
|
71
71
|
throw new Error("vitest-bats: schema must be a Standard Schema validator or a JSON Schema object");
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
//#endregion
|
|
75
74
|
export { isStandardSchema, validate };
|
package/setup.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { resetAllBuilders } from "./runtime.js";
|
|
2
1
|
import { batsMatchers } from "./matchers.js";
|
|
2
|
+
import { resetAllBuilders } from "./runtime.js";
|
|
3
3
|
import { beforeEach, expect } from "vitest";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/setup.ts
|
|
6
6
|
expect.extend(batsMatchers);
|
|
7
7
|
beforeEach(() => {
|
|
8
8
|
resetAllBuilders();
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
//#endregion
|
|
12
11
|
export { };
|