1 | declare module 'assert' {
|
2 |
|
3 | function assert(value: any, message?: string | Error): asserts value;
|
4 | namespace assert {
|
5 | class AssertionError extends Error {
|
6 | actual: any;
|
7 | expected: any;
|
8 | operator: string;
|
9 | generatedMessage: boolean;
|
10 | code: 'ERR_ASSERTION';
|
11 |
|
12 | constructor(options?: {
|
13 |
|
14 | message?: string | undefined;
|
15 |
|
16 | actual?: any;
|
17 |
|
18 | expected?: any;
|
19 |
|
20 | operator?: string | undefined;
|
21 |
|
22 |
|
23 | stackStartFn?: Function | undefined;
|
24 | });
|
25 | }
|
26 |
|
27 | class CallTracker {
|
28 | calls(exact?: number): () => void;
|
29 | calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
|
30 | report(): CallTrackerReportInformation[];
|
31 | verify(): void;
|
32 | }
|
33 | interface CallTrackerReportInformation {
|
34 | message: string;
|
35 |
|
36 | actual: number;
|
37 |
|
38 | expected: number;
|
39 |
|
40 | operator: string;
|
41 |
|
42 | stack: object;
|
43 | }
|
44 |
|
45 | type AssertPredicate = RegExp | (new () => object) | ((thrown: any) => boolean) | object | Error;
|
46 |
|
47 | function fail(message?: string | Error): never;
|
48 | /** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
|
49 | function fail(
|
50 | actual: any,
|
51 | expected: any,
|
52 | message?: string | Error,
|
53 | operator?: string,
|
54 |
|
55 | stackStartFn?: Function,
|
56 | ): never;
|
57 | function ok(value: any, message?: string | Error): asserts value;
|
58 | /** @deprecated since v9.9.0 - use strictEqual() instead. */
|
59 | function equal(actual: any, expected: any, message?: string | Error): void;
|
60 | /** @deprecated since v9.9.0 - use notStrictEqual() instead. */
|
61 | function notEqual(actual: any, expected: any, message?: string | Error): void;
|
62 | /** @deprecated since v9.9.0 - use deepStrictEqual() instead. */
|
63 | function deepEqual(actual: any, expected: any, message?: string | Error): void;
|
64 | /** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */
|
65 | function notDeepEqual(actual: any, expected: any, message?: string | Error): void;
|
66 | function strictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
|
67 | function notStrictEqual(actual: any, expected: any, message?: string | Error): void;
|
68 | function deepStrictEqual<T>(actual: any, expected: T, message?: string | Error): asserts actual is T;
|
69 | function notDeepStrictEqual(actual: any, expected: any, message?: string | Error): void;
|
70 |
|
71 | function throws(block: () => any, message?: string | Error): void;
|
72 | function throws(block: () => any, error: AssertPredicate, message?: string | Error): void;
|
73 | function doesNotThrow(block: () => any, message?: string | Error): void;
|
74 | function doesNotThrow(block: () => any, error: AssertPredicate, message?: string | Error): void;
|
75 |
|
76 | function ifError(value: any): asserts value is null | undefined;
|
77 |
|
78 | function rejects(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
|
79 | function rejects(
|
80 | block: (() => Promise<any>) | Promise<any>,
|
81 | error: AssertPredicate,
|
82 | message?: string | Error,
|
83 | ): Promise<void>;
|
84 | function doesNotReject(block: (() => Promise<any>) | Promise<any>, message?: string | Error): Promise<void>;
|
85 | function doesNotReject(
|
86 | block: (() => Promise<any>) | Promise<any>,
|
87 | error: AssertPredicate,
|
88 | message?: string | Error,
|
89 | ): Promise<void>;
|
90 |
|
91 | function match(value: string, regExp: RegExp, message?: string | Error): void;
|
92 | function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
|
93 |
|
94 | const strict: Omit<
|
95 | typeof assert,
|
96 | | 'equal'
|
97 | | 'notEqual'
|
98 | | 'deepEqual'
|
99 | | 'notDeepEqual'
|
100 | | 'ok'
|
101 | | 'strictEqual'
|
102 | | 'deepStrictEqual'
|
103 | | 'ifError'
|
104 | | 'strict'
|
105 | > & {
|
106 | (value: any, message?: string | Error): asserts value;
|
107 | equal: typeof strictEqual;
|
108 | notEqual: typeof notStrictEqual;
|
109 | deepEqual: typeof deepStrictEqual;
|
110 | notDeepEqual: typeof notDeepStrictEqual;
|
111 |
|
112 | // Mapped types and assertion functions are incompatible?
|
113 | // TS2775: Assertions require every name in the call target
|
114 | // to be declared with an explicit type annotation.
|
115 | ok: typeof ok;
|
116 | strictEqual: typeof strictEqual;
|
117 | deepStrictEqual: typeof deepStrictEqual;
|
118 | ifError: typeof ifError;
|
119 | strict: typeof strict;
|
120 | };
|
121 | }
|
122 |
|
123 | export = assert;
|
124 | }
|
125 |
|
\ | No newline at end of file |