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