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