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