UNPKG

1.33 kBTypeScriptView Raw
1import { Options as CoreOptions } from "empower-core";
2import { Formatter } from "power-assert-formatter";
3
4/**
5 * Enhances Power Assert feature to assert function/object.
6 *
7 * @param originalAssert An instance of standard `assert` function or any assert-like object to enhance.
8 * @param formatter A formatter function created by power-assert-formatter.
9 * @param options Configuration options. If not passed, default options will be used.
10 * @return Enhanced assert function/object.
11 */
12declare function empower<T>(originalAssert: T, formatter: Formatter, options?: empower.Options): T;
13
14declare namespace empower {
15 // The omitted options can be provided, but they will be always overridden.
16 type Options = Omit<CoreOptions, "modifyMessageBeforeAssert" | "onError"> & {
17 /**
18 * If truthy, modify message property of `AssertionError` on rethrow.
19 *
20 * @default false
21 */
22 modifyMessageOnRethrow?: boolean | undefined;
23 /**
24 * If truthy, add `powerAssertContext` property to `AssertionError` on rethrow.
25 *
26 * @default false
27 */
28 saveContextOnRethrow?: boolean | undefined;
29 };
30
31 /**
32 * Returns default options object for `empower` function.
33 */
34 function defaultOptions(): Required<Options>;
35}
36
37export = empower;