@executablemd/testing 0.3.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/LICENSE +21 -0
- package/esm/core/mod.js +55 -0
- package/esm/core/src/api.js +31 -0
- package/esm/core/src/collect.js +24 -0
- package/esm/core/src/component-api.js +47 -0
- package/esm/core/src/content-context.js +23 -0
- package/esm/core/src/deno-compiler.js +51 -0
- package/esm/core/src/errors.js +13 -0
- package/esm/core/src/eval-context.js +13 -0
- package/esm/core/src/eval-handler.js +79 -0
- package/esm/core/src/eval-interpolate.js +63 -0
- package/esm/core/src/eval-transform.js +378 -0
- package/esm/core/src/execute.js +378 -0
- package/esm/core/src/expand.js +988 -0
- package/esm/core/src/frontmatter.js +98 -0
- package/esm/core/src/heal.js +29 -0
- package/esm/core/src/interpolate.js +39 -0
- package/esm/core/src/modifiers/daemon.js +60 -0
- package/esm/core/src/modifiers/persist.js +35 -0
- package/esm/core/src/modifiers/timeout.js +55 -0
- package/esm/core/src/modifiers.js +113 -0
- package/esm/core/src/output/normalize.js +33 -0
- package/esm/core/src/output/terminal.js +20 -0
- package/esm/core/src/render.js +30 -0
- package/esm/core/src/replay-stream.js +58 -0
- package/esm/core/src/sample-api.js +45 -0
- package/esm/core/src/scanner.js +632 -0
- package/esm/core/src/temp-file-compiler.js +68 -0
- package/esm/core/src/types.js +7 -0
- package/esm/core/src/validate.js +82 -0
- package/esm/durable-streams/combinators.js +227 -0
- package/esm/durable-streams/context.js +13 -0
- package/esm/durable-streams/divergence.js +56 -0
- package/esm/durable-streams/each.js +193 -0
- package/esm/durable-streams/effect.js +273 -0
- package/esm/durable-streams/ephemeral.js +80 -0
- package/esm/durable-streams/errors.js +92 -0
- package/esm/durable-streams/http-stream.js +207 -0
- package/esm/durable-streams/mod.js +34 -0
- package/esm/durable-streams/operations.js +88 -0
- package/esm/durable-streams/replay-guard.js +87 -0
- package/esm/durable-streams/replay-index.js +132 -0
- package/esm/durable-streams/run.js +137 -0
- package/esm/durable-streams/serialize.js +65 -0
- package/esm/durable-streams/stream.js +56 -0
- package/esm/durable-streams/types.js +10 -0
- package/esm/package.json +3 -0
- package/esm/runtime/apis.js +237 -0
- package/esm/runtime/find-free-port.js +33 -0
- package/esm/runtime/mod.js +20 -0
- package/esm/testing/npm/src/_dnt.polyfills.js +1 -0
- package/esm/testing/npm/src/_dnt.shims.js +57 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/almost_equals.js +47 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/array_includes.js +65 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/assert.js +23 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/assertion_error.js +30 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/equal.js +194 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/equals.js +61 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/exists.js +27 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/fail.js +20 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/false.js +23 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/greater.js +29 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/greater_or_equal.js +29 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/instance_of.js +52 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/is_error.js +53 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/less.js +28 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/less_or_equal.js +29 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/match.js +26 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/mod.js +45 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/not_equals.js +39 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/not_instance_of.js +29 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/not_match.js +26 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/not_strict_equals.js +32 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/object_match.js +177 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/rejects.js +53 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/strict_equals.js +58 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/string_includes.js +26 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/throws.js +44 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/unimplemented.js +20 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/assert/1.0.19/unreachable.js +20 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/internal/1.0.14/build_message.js +116 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/internal/1.0.14/diff.js +277 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/internal/1.0.14/diff_str.js +181 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/internal/1.0.14/format.js +70 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/internal/1.0.14/styles.js +207 -0
- package/esm/testing/npm/src/deps/jsr.io/@std/internal/1.0.14/types.js +3 -0
- package/esm/testing/npm/src/mod.js +27 -0
- package/esm/testing/npm/src/src/assertions.js +250 -0
- package/esm/testing/npm/src/src/handlers.js +245 -0
- package/esm/testing/npm/src/src/journal.js +152 -0
- package/esm/testing/npm/src/src/test-api.js +33 -0
- package/esm/testing/npm/src/src/use-testing.js +79 -0
- package/esm/testing/npm/src/src/vocabulary.js +111 -0
- package/package.json +35 -0
- package/types/_dnt.polyfills.d.ts +6 -0
- package/types/_dnt.shims.d.ts +1 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/almost_equals.d.ts +29 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/array_includes.d.ts +28 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/assert.d.ts +16 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/assertion_error.d.ts +25 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/equal.d.ts +24 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/equals.d.ts +36 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/exists.d.ts +17 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/fail.d.ts +14 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/false.d.ts +18 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/greater.d.ts +19 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/greater_or_equal.d.ts +19 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/instance_of.d.ts +22 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/is_error.d.ts +24 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/less.d.ts +18 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/less_or_equal.d.ts +19 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/match.d.ts +17 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/mod.d.ts +43 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/not_equals.d.ts +26 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/not_instance_of.d.ts +19 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/not_match.d.ts +17 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/not_strict_equals.d.ts +22 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/object_match.d.ts +28 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/rejects.d.ts +41 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/strict_equals.d.ts +23 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/string_includes.d.ts +17 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/throws.d.ts +44 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/unimplemented.d.ts +14 -0
- package/types/deps/jsr.io/@std/assert/1.0.19/unreachable.d.ts +14 -0
- package/types/deps/jsr.io/@std/internal/1.0.14/build_message.d.ts +79 -0
- package/types/deps/jsr.io/@std/internal/1.0.14/diff.d.ts +139 -0
- package/types/deps/jsr.io/@std/internal/1.0.14/diff_str.d.ts +98 -0
- package/types/deps/jsr.io/@std/internal/1.0.14/format.d.ts +28 -0
- package/types/deps/jsr.io/@std/internal/1.0.14/styles.d.ts +158 -0
- package/types/deps/jsr.io/@std/internal/1.0.14/types.d.ts +24 -0
- package/types/mod.d.ts +29 -0
- package/types/src/assertions.d.ts +55 -0
- package/types/src/handlers.d.ts +18 -0
- package/types/src/journal.d.ts +29 -0
- package/types/src/test-api.d.ts +54 -0
- package/types/src/use-testing.d.ts +25 -0
- package/types/src/vocabulary.d.ts +34 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test Api — contextual operations for testing mode (specs/testing-spec.md).
|
|
3
|
+
*
|
|
4
|
+
* `testing` is the activation switch: false by default, true beneath
|
|
5
|
+
* `<Testing>` (or root activation via a `useTesting()` session).
|
|
6
|
+
* Both perform the identical `Test.around({ testing: () => true })` install,
|
|
7
|
+
* which is what makes `xmd test` equivalent to wrapping the entrypoint in
|
|
8
|
+
* `<Testing>`.
|
|
9
|
+
*
|
|
10
|
+
* `record` delegates outward through nested collectors, so every enclosing
|
|
11
|
+
* `<Testing>` boundary and the run-level collector observe each completed
|
|
12
|
+
* test. `boundary` reports each `<Testing>` element's aggregate outcome.
|
|
13
|
+
*/
|
|
14
|
+
import type { Operation } from "effection";
|
|
15
|
+
/** A completed test, in discovery order. Never holds rendered markdown. */
|
|
16
|
+
export interface TestResult {
|
|
17
|
+
status: "pass" | "fail";
|
|
18
|
+
name?: string;
|
|
19
|
+
/** "path:line:column" ("line:column" for dynamically scanned sources). */
|
|
20
|
+
location: string;
|
|
21
|
+
error?: {
|
|
22
|
+
kind: "assertion" | "timeout" | "teardown" | "error";
|
|
23
|
+
message: string;
|
|
24
|
+
actual?: string;
|
|
25
|
+
expected?: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** Aggregate outcome of one `<Testing>` boundary. */
|
|
29
|
+
export interface BoundaryOutcome {
|
|
30
|
+
tests: number;
|
|
31
|
+
failed: number;
|
|
32
|
+
}
|
|
33
|
+
export interface TestApi {
|
|
34
|
+
/** Whether testing mode is active in the current scope. */
|
|
35
|
+
testing: boolean;
|
|
36
|
+
/** Whether expansion is currently inside a `<Test>` body. */
|
|
37
|
+
inTest: boolean;
|
|
38
|
+
/** Whether assertion diagnostics render during regular execution. */
|
|
39
|
+
verbose: boolean;
|
|
40
|
+
/** Whether a useTesting() session is already active in this scope. */
|
|
41
|
+
sessionActive: boolean;
|
|
42
|
+
/** Record a completed test. Collectors delegate outward via `next`. */
|
|
43
|
+
record(result: TestResult): Operation<void>;
|
|
44
|
+
/** Completed tests recorded by the nearest collector, discovery order. */
|
|
45
|
+
results(): Operation<TestResult[]>;
|
|
46
|
+
/** Report a `<Testing>` boundary's aggregate outcome. */
|
|
47
|
+
boundary(outcome: BoundaryOutcome): Operation<void>;
|
|
48
|
+
}
|
|
49
|
+
export declare const Test: import("@effectionx/context-api").Api<TestApi>;
|
|
50
|
+
export declare const testing: Operation<boolean>, inTest: Operation<boolean>, verbose: Operation<boolean>, sessionActive: Operation<boolean>, record: (result: TestResult) => Operation<void>, results: () => Operation<TestResult[]>, boundary: (outcome: BoundaryOutcome) => Operation<void>;
|
|
51
|
+
/** A document execution failed its testing outcome (test failures or zero tests). */
|
|
52
|
+
export declare class TestFailureError extends Error {
|
|
53
|
+
name: string;
|
|
54
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useTesting — scope-local testing composition (specs/testing-spec.md).
|
|
3
|
+
*
|
|
4
|
+
* One `useTesting()` session per execution scope: it installs the testing
|
|
5
|
+
* vocabulary, the collection and completion-policy middleware, and root
|
|
6
|
+
* activation, then returns a session handle whose `results` operation
|
|
7
|
+
* snapshots completed tests in discovery order. Every install is removed
|
|
8
|
+
* with the session's Effection scope.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const tests = yield* useTesting();
|
|
12
|
+
* const execution = yield* execute(options);
|
|
13
|
+
* const outcome = yield* execution; // Result<string>
|
|
14
|
+
* const results = yield* tests.results;
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
import type { Operation } from "effection";
|
|
18
|
+
import type { TestResult } from "./test-api.js";
|
|
19
|
+
export interface Testing {
|
|
20
|
+
/** Immutable snapshot of completed tests, in discovery order. */
|
|
21
|
+
readonly results: Operation<readonly TestResult[]>;
|
|
22
|
+
}
|
|
23
|
+
export declare function useTesting(options?: {
|
|
24
|
+
verbose?: boolean;
|
|
25
|
+
}): Operation<Testing>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vocabulary registration (specs/testing-spec.md).
|
|
3
|
+
*
|
|
4
|
+
* Teaches the expansion loop the testing words — `<Testing>`, `<Test>`, and
|
|
5
|
+
* the assertion components — via the core `expandInvocation` hook, and
|
|
6
|
+
* decorates the core Execution Api so explicit `<Testing>` boundaries affect
|
|
7
|
+
* the execution outcome even when root testing is inactive.
|
|
8
|
+
*
|
|
9
|
+
* Registration is distinct from activation: installing the vocabulary
|
|
10
|
+
* leaves `testing` false, so `<Test>` skips and assertions stay usable.
|
|
11
|
+
* Root activation is `useTesting()`'s job.
|
|
12
|
+
*
|
|
13
|
+
* Installs are scope-local — call this inside a bounded scope (one CLI
|
|
14
|
+
* command invocation, one `scoped()` block).
|
|
15
|
+
*/
|
|
16
|
+
import type { Operation } from "effection";
|
|
17
|
+
import type { DocumentExecution } from "@executablemd/core";
|
|
18
|
+
import type { TestHandlers } from "./handlers.js";
|
|
19
|
+
export declare function installTestingVocabulary(options?: {
|
|
20
|
+
verbose?: boolean;
|
|
21
|
+
}): Operation<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Install a specific handler set. Internal seam: tests inject handlers built
|
|
24
|
+
* with a short timeout; the public path always uses the fixed 20 seconds.
|
|
25
|
+
*/
|
|
26
|
+
export declare function installHandlers(handlers: TestHandlers, options?: {
|
|
27
|
+
verbose?: boolean;
|
|
28
|
+
}): Operation<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Map an execution's completion: an `Ok` becomes `Err(failure())` when the
|
|
31
|
+
* policy reports one, after the inner completion — and therefore its closed
|
|
32
|
+
* output stream — settles. An existing `Err` passes through unchanged.
|
|
33
|
+
*/
|
|
34
|
+
export declare function decorateCompletion(inner: DocumentExecution, failure: () => Error | undefined): DocumentExecution;
|