1 |
|
2 | declare function assert(value: any, message?: string | Error): asserts value;
|
3 | declare namespace assert {
|
4 | class AssertionError extends Error {
|
5 | actual: any;
|
6 | expected: any;
|
7 | operator: string;
|
8 | generatedMessage: boolean;
|
9 | code: "ERR_ASSERTION";
|
10 |
|
11 | constructor(options?: {
|
12 |
|
13 | message?: string | undefined;
|
14 |
|
15 | actual?: any;
|
16 |
|
17 | expected?: any;
|
18 |
|
19 | operator?: string | undefined;
|
20 |
|
21 |
|
22 | stackStartFn?: Function | undefined;
|
23 | });
|
24 | }
|
25 |
|
26 | type AssertPredicate = RegExp | (new() => object) | ((thrown: any) => boolean) | object | Error;
|
27 |
|
28 | function fail(message?: string | Error): never;
|
29 | /** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
|
30 | function fail(
|
31 | actual: any,
|
32 | expected: any,
|
33 | message?: string | Error,
|
34 | operator?: string,
|
35 |
|
36 | stackStartFn?: Function,
|
37 | ): never;
|
38 | function ok(value: any, message?: string | Error): asserts value;
|
39 | /** @deprecated since v9.9.0 - use strictEqual() instead. */
|
40 | function equal(actual: any, expected: any, message?: string | Error): void;
|
41 | /** @deprecated since v9.9.0 - use notStrictEqual() instead. */
|
42 | function notEqual(actual: any, expected: any, message?: string | Error): void;
|
43 | /** @deprecated since v9.9.0 - use deepStrictEqual() instead. */
|
44 | function deepEqual(actual: any, expected: any, message?: string | Error): void;
|
45 | /** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */
|
46 | function notDeepEqual(actual: any, expected: any, message?: string | Error): void;
|
47 | function strictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
|
48 | function notStrictEqual(actual: any, expected: any, message?: string | Error): void;
|
49 | function deepStrictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
|
50 | function notDeepStrictEqual(actual: any, expected: any, message?: string | Error): void;
|
51 |
|
52 | function throws(block: () => any, message?: string | Error): void;
|
53 | function throws(block: () => any, error: AssertPredicate, message?: string | Error): void;
|
54 | function doesNotThrow(block: () => any, message?: string | Error): void;
|
55 | function doesNotThrow(block: () => any, error: AssertPredicate, message?: string | Error): void;
|
56 |
|
57 | function ifError(value: any): asserts value is null | undefined;
|
58 |
|
59 | function rejects(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
|
60 | function rejects(
|
61 | block: (() => Promise<any>) | Promise<any>,
|
62 | error: AssertPredicate,
|
63 | message?: string | Error,
|
64 | ): Promise<void>;
|
65 | function doesNotReject(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
|
66 | function doesNotReject(
|
67 | block: (() => Promise<any>) | Promise<any>,
|
68 | error: AssertPredicate,
|
69 | message?: string | Error,
|
70 | ): Promise<void>;
|
71 |
|
72 | function match(value: string, regExp: RegExp, message?: string | Error): void;
|
73 | function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
|
74 |
|
75 | const strict:
|
76 | & Omit<
|
77 | typeof assert,
|
78 | | "equal"
|
79 | | "notEqual"
|
80 | | "deepEqual"
|
81 | | "notDeepEqual"
|
82 | | "ok"
|
83 | | "strictEqual"
|
84 | | "deepStrictEqual"
|
85 | | "ifError"
|
86 | | "strict"
|
87 | >
|
88 | & {
|
89 | (value: any, message?: string | Error): asserts value;
|
90 | equal: typeof strictEqual;
|
91 | notEqual: typeof notStrictEqual;
|
92 | deepEqual: typeof deepStrictEqual;
|
93 | notDeepEqual: typeof notDeepStrictEqual;
|
94 |
|
95 |
|
96 |
|
97 |
|
98 | ok: typeof ok;
|
99 | strictEqual: typeof strictEqual;
|
100 | deepStrictEqual: typeof deepStrictEqual;
|
101 | ifError: typeof ifError;
|
102 | strict: typeof strict;
|
103 | };
|
104 | }
|
105 |
|
106 | export = assert;
|