tina4-nodejs 3.13.162 → 3.13.163

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.
@@ -13,7 +13,8 @@
13
13
  * return a + b;
14
14
  * });
15
15
  *
16
- * runAll();
16
+ * runAll(); // synchronous test functions
17
+ * await runAllAsync(); // async test functions (awaited, with a timeout)
17
18
  *
18
19
  * The builders are named expect* — DESCRIPTORS that record an expectation for the
19
20
  * runner — deliberately distinct from the xUnit assert* on Tina4Test (test.ts),
@@ -52,11 +53,33 @@ export declare function expectFalse(args: unknown[]): Assertion;
52
53
  * const myFn = tests(assertEqual([1,2], 3))(function myFn(a,b) { return a+b; });
53
54
  */
54
55
  export declare function tests(...assertions: Assertion[]): <T extends (...args: unknown[]) => unknown>(fn: T) => T;
55
- /** Run all registered tests. Returns results summary. */
56
- export declare function runAll(options?: {
56
+ interface RunOptions {
57
57
  quiet?: boolean;
58
58
  failfast?: boolean;
59
- }): TestResults;
59
+ }
60
+ interface AsyncRunOptions extends RunOptions {
61
+ /** Per-call limit in milliseconds for an async test function (default 30000). */
62
+ timeoutMs?: number;
63
+ }
64
+ /**
65
+ * Run all registered tests synchronously. Returns the results summary.
66
+ *
67
+ * A test function that returns a Promise (an async function) cannot be judged
68
+ * here: its result is not known yet. It is reported as an ERROR naming
69
+ * `runAllAsync()`, never as a pass. Use `await runAllAsync()` for async tests.
70
+ */
71
+ export declare function runAll(options?: RunOptions): TestResults;
72
+ /**
73
+ * Run all registered tests, awaiting each test function. Resolves to the
74
+ * results summary.
75
+ *
76
+ * An async function is judged on what it resolves to or rejects with. A call
77
+ * that has not settled after `timeoutMs` (default 30000) is reported as an
78
+ * error, so one stuck test cannot hang the run. `timeoutMs: Infinity` turns the
79
+ * timeout off; any other value must be a positive number of milliseconds no
80
+ * larger than 2147483647 (the largest delay a Node timer accepts).
81
+ */
82
+ export declare function runAllAsync(options?: AsyncRunOptions): Promise<TestResults>;
60
83
  /** Reset the test registry (useful between test runs). */
61
84
  export declare function reset(): void;
62
85
  export {};