UNPKG

73.6 kBTypeScriptView Raw
1// Type definitions for chai 4.3
2// Project: http://chaijs.com/
3// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
4// Andrew Brown <https://github.com/AGBrown>
5// Olivier Chevet <https://github.com/olivr70>
6// Matt Wistrand <https://github.com/mwistrand>
7// Shaun Luttin <https://github.com/shaunluttin>
8// Satana Charuwichitratana <https://github.com/micksatana>
9// Erik Schierboom <https://github.com/ErikSchierboom>
10// Bogdan Paranytsia <https://github.com/bparan>
11// CXuesong <https://github.com/CXuesong>
12// Joey Kilpatrick <https://github.com/joeykilpatrick>
13// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
14// TypeScript Version: 3.0
15
16declare namespace Chai {
17 type Message = string | (() => string);
18 type ObjectProperty = string | symbol | number;
19
20 interface PathInfo {
21 parent: object;
22 name: string;
23 value?: any;
24 exists: boolean;
25 }
26
27 interface ErrorConstructor {
28 new(...args: any[]): Error;
29 }
30
31 interface ChaiUtils {
32 addChainableMethod(
33 // object to define the method on, e.g. chai.Assertion.prototype
34 ctx: object,
35 // method name
36 name: string,
37 // method itself; any arguments
38 method: (...args: any[]) => void,
39 // called when property is accessed
40 chainingBehavior?: () => void
41 ): void;
42 overwriteChainableMethod(
43 ctx: object,
44 name: string,
45 method: (...args: any[]) => void,
46 chainingBehavior?: () => void
47 ): void;
48 addLengthGuard(
49 fn: Function,
50 assertionName: string,
51 isChainable: boolean
52 ): void;
53 addMethod(ctx: object, name: string, method: Function): void;
54 addProperty(ctx: object, name: string, getter: () => any): void;
55 overwriteMethod(ctx: object, name: string, method: Function): void;
56 overwriteProperty(ctx: object, name: string, getter: () => any): void;
57 compareByInspect(a: object, b: object): -1 | 1;
58 expectTypes(obj: object, types: string[]): void;
59 flag(obj: object, key: string, value?: any): any;
60 getActual(obj: object, args: AssertionArgs): any;
61 getProperties(obj: object): string[];
62 getEnumerableProperties(obj: object): string[];
63 getOwnEnumerablePropertySymbols(obj: object): symbol[];
64 getOwnEnumerableProperties(obj: object): Array<string | symbol>;
65 getMessage(errorLike: Error | string): string;
66 getMessage(obj: any, args: AssertionArgs): string;
67 inspect(obj: any, showHidden?: boolean, depth?: number, colors?: boolean): string;
68 isProxyEnabled(): boolean;
69 objDisplay(obj: object): void;
70 proxify(obj: object, nonChainableMethodName: string): object;
71 test(obj: object, args: AssertionArgs): boolean;
72 transferFlags(assertion: Assertion, obj: object, includeAll?: boolean): void;
73 compatibleInstance(thrown: Error, errorLike: Error | ErrorConstructor): boolean;
74 compatibleConstructor(thrown: Error, errorLike: Error | ErrorConstructor): boolean;
75 compatibleMessage(thrown: Error, errMatcher: string | RegExp): boolean;
76 getConstructorName(constructorFn: Function): string;
77 getFuncName(constructorFn: Function): string | null;
78
79 // Reexports from pathval:
80 hasProperty(obj: object | undefined | null, name: ObjectProperty): boolean;
81 getPathInfo(obj: object, path: string): PathInfo;
82 getPathValue(obj: object, path: string): object | undefined;
83 }
84
85 type ChaiPlugin = (chai: ChaiStatic, utils: ChaiUtils) => void;
86
87 interface ChaiStatic {
88 expect: ExpectStatic;
89 should(): Should;
90 /**
91 * Provides a way to extend the internals of Chai
92 */
93 use(fn: ChaiPlugin): ChaiStatic;
94 util: ChaiUtils;
95 assert: AssertStatic;
96 config: Config;
97 Assertion: AssertionStatic;
98 AssertionError: typeof AssertionError;
99 version: string;
100 }
101
102 export interface ExpectStatic {
103 (val: any, message?: string): Assertion;
104 fail(message?: string): never;
105 fail(actual: any, expected: any, message?: string, operator?: Operator): never;
106 }
107
108 export interface AssertStatic extends Assert {
109 }
110
111 // chai.Assertion.prototype.assert arguments
112 type AssertionArgs = [
113 // 'expression to be tested'
114 // This parameter is unused and the docs list its type as
115 // 'Philosophical', which is mentioned nowhere else in the source. Do
116 // with that what you will!
117 any,
118 Message, // message if value fails
119 Message, // message if negated value fails
120 any, // expected value
121 any?, // actual value
122 boolean? // showDiff
123 ];
124
125 export interface AssertionPrototype {
126 assert(...args: AssertionArgs): void;
127 _obj: any;
128 }
129
130 export interface AssertionStatic extends AssertionPrototype {
131 prototype: AssertionPrototype;
132
133 new(target: any, message?: string, ssfi?: Function, lockSsfi?: boolean): Assertion;
134
135 // Deprecated properties:
136 includeStack: boolean;
137 showDiff: boolean;
138
139 // Partials of functions on ChaiUtils:
140 addProperty(name: string, getter: (this: AssertionStatic) => any): void;
141 addMethod(name: string, method: (this: AssertionStatic, ...args: any[]) => any): void;
142 addChainableMethod(
143 name: string,
144 method: (this: AssertionStatic, ...args: any[]) => void,
145 chainingBehavior?: () => void
146 ): void;
147 overwriteProperty(name: string, getter: (this: AssertionStatic) => any): void;
148 overwriteMethod(name: string, method: (this: AssertionStatic, ...args: any[]) => any): void;
149 overwriteChainableMethod(
150 name: string,
151 method: (this: AssertionStatic, ...args: any[]) => void,
152 chainingBehavior?: () => void
153 ): void;
154 }
155
156 export type Operator = string; // "==" | "===" | ">" | ">=" | "<" | "<=" | "!=" | "!==";
157
158 export type OperatorComparable = boolean | null | number | string | undefined | Date;
159
160 interface ShouldAssertion {
161 equal(value1: any, value2: any, message?: string): void;
162 Throw: ShouldThrow;
163 throw: ShouldThrow;
164 exist(value: any, message?: string): void;
165 }
166
167 interface Should extends ShouldAssertion {
168 not: ShouldAssertion;
169 fail(message?: string): never;
170 fail(actual: any, expected: any, message?: string, operator?: Operator): never;
171 }
172
173 interface ShouldThrow {
174 (actual: Function, expected?: string | RegExp, message?: string): void;
175 (actual: Function, constructor: Error | Function, expected?: string | RegExp, message?: string): void;
176 }
177
178 interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
179 not: Assertion;
180 deep: Deep;
181 ordered: Ordered;
182 nested: Nested;
183 own: Own;
184 any: KeyFilter;
185 all: KeyFilter;
186 a: Assertion;
187 an: Assertion;
188 include: Include;
189 includes: Include;
190 contain: Include;
191 contains: Include;
192 ok: Assertion;
193 true: Assertion;
194 false: Assertion;
195 null: Assertion;
196 undefined: Assertion;
197 NaN: Assertion;
198 exist: Assertion;
199 empty: Assertion;
200 arguments: Assertion;
201 Arguments: Assertion;
202 finite: Assertion;
203 equal: Equal;
204 equals: Equal;
205 eq: Equal;
206 eql: Equal;
207 eqls: Equal;
208 property: Property;
209 ownProperty: Property;
210 haveOwnProperty: Property;
211 ownPropertyDescriptor: OwnPropertyDescriptor;
212 haveOwnPropertyDescriptor: OwnPropertyDescriptor;
213 length: Length;
214 lengthOf: Length;
215 match: Match;
216 matches: Match;
217 string(string: string, message?: string): Assertion;
218 keys: Keys;
219 key(string: string): Assertion;
220 throw: Throw;
221 throws: Throw;
222 Throw: Throw;
223 respondTo: RespondTo;
224 respondsTo: RespondTo;
225 itself: Assertion;
226 satisfy: Satisfy;
227 satisfies: Satisfy;
228 closeTo: CloseTo;
229 approximately: CloseTo;
230 members: Members;
231 increase: PropertyChange;
232 increases: PropertyChange;
233 decrease: PropertyChange;
234 decreases: PropertyChange;
235 change: PropertyChange;
236 changes: PropertyChange;
237 extensible: Assertion;
238 sealed: Assertion;
239 frozen: Assertion;
240 oneOf: OneOf;
241 }
242
243 interface LanguageChains {
244 to: Assertion;
245 be: Assertion;
246 been: Assertion;
247 is: Assertion;
248 that: Assertion;
249 which: Assertion;
250 and: Assertion;
251 has: Assertion;
252 have: Assertion;
253 with: Assertion;
254 at: Assertion;
255 of: Assertion;
256 same: Assertion;
257 but: Assertion;
258 does: Assertion;
259 }
260
261 interface NumericComparison {
262 above: NumberComparer;
263 gt: NumberComparer;
264 greaterThan: NumberComparer;
265 least: NumberComparer;
266 gte: NumberComparer;
267 greaterThanOrEqual: NumberComparer;
268 below: NumberComparer;
269 lt: NumberComparer;
270 lessThan: NumberComparer;
271 most: NumberComparer;
272 lte: NumberComparer;
273 lessThanOrEqual: NumberComparer;
274 within(start: number, finish: number, message?: string): Assertion;
275 within(start: Date, finish: Date, message?: string): Assertion;
276 }
277
278 interface NumberComparer {
279 (value: number | Date, message?: string): Assertion;
280 }
281
282 interface TypeComparison {
283 (type: string, message?: string): Assertion;
284 instanceof: InstanceOf;
285 instanceOf: InstanceOf;
286 }
287
288 interface InstanceOf {
289 (constructor: any, message?: string): Assertion;
290 }
291
292 interface CloseTo {
293 (expected: number, delta: number, message?: string): Assertion;
294 }
295
296 interface Nested {
297 include: Include;
298 includes: Include;
299 contain: Include;
300 contains: Include;
301 property: Property;
302 members: Members;
303 }
304
305 interface Own {
306 include: Include;
307 includes: Include;
308 contain: Include;
309 contains: Include;
310 property: Property;
311 }
312
313 interface Deep extends KeyFilter {
314 be: Assertion;
315 equal: Equal;
316 equals: Equal;
317 eq: Equal;
318 include: Include;
319 includes: Include;
320 contain: Include;
321 contains: Include;
322 property: Property;
323 ordered: Ordered;
324 nested: Nested;
325 oneOf: OneOf;
326 own: Own;
327 }
328
329 interface Ordered {
330 members: Members;
331 }
332
333 interface KeyFilter {
334 keys: Keys;
335 members: Members;
336 }
337
338 interface Equal {
339 (value: any, message?: string): Assertion;
340 }
341
342 interface Property {
343 (name: string | symbol, value: any, message?: string): Assertion;
344 (name: string | symbol, message?: string): Assertion;
345 }
346
347 interface OwnPropertyDescriptor {
348 (name: string | symbol, descriptor: PropertyDescriptor, message?: string): Assertion;
349 (name: string | symbol, message?: string): Assertion;
350 }
351
352 interface Length extends LanguageChains, NumericComparison {
353 (length: number, message?: string): Assertion;
354 }
355
356 interface Include {
357 (value: any, message?: string): Assertion;
358 keys: Keys;
359 deep: Deep;
360 ordered: Ordered;
361 members: Members;
362 any: KeyFilter;
363 all: KeyFilter;
364 oneOf: OneOf;
365 }
366
367 interface OneOf {
368 (list: ReadonlyArray<unknown>, message?: string): Assertion;
369 }
370
371 interface Match {
372 (regexp: RegExp, message?: string): Assertion;
373 }
374
375 interface Keys {
376 (...keys: string[]): Assertion;
377 (keys: ReadonlyArray<any> | Object): Assertion;
378 }
379
380 interface Throw {
381 (expected?: string | RegExp, message?: string): Assertion;
382 (constructor: Error | Function, expected?: string | RegExp, message?: string): Assertion;
383 }
384
385 interface RespondTo {
386 (method: string, message?: string): Assertion;
387 }
388
389 interface Satisfy {
390 (matcher: Function, message?: string): Assertion;
391 }
392
393 interface Members {
394 (set: ReadonlyArray<any>, message?: string): Assertion;
395 }
396
397 interface PropertyChange {
398 (object: Object, property?: string, message?: string): DeltaAssertion;
399 }
400
401 interface DeltaAssertion extends Assertion {
402 by(delta: number, msg?: string): Assertion;
403 }
404
405 export interface Assert {
406 /**
407 * @param expression Expression to test for truthiness.
408 * @param message Message to display on error.
409 */
410 (expression: any, message?: string): asserts expression;
411
412 /**
413 * Throws a failure.
414 *
415 * @param message Message to display on error.
416 * @remarks Node.js assert module-compatible.
417 */
418 fail(message?: string): never;
419
420 /**
421 * Throws a failure.
422 *
423 * @type T Type of the objects.
424 * @param actual Actual value.
425 * @param expected Potential expected value.
426 * @param message Message to display on error.
427 * @param operator Comparison operator, if not strict equality.
428 * @remarks Node.js assert module-compatible.
429 */
430 fail<T>(actual: T, expected: T, message?: string, operator?: Operator): never;
431
432 /**
433 * Asserts that object is truthy.
434 *
435 * @type T Type of object.
436 * @param object Object to test.
437 * @param message Message to display on error.
438 */
439 isOk<T>(value: T, message?: string): void;
440
441 /**
442 * Asserts that object is truthy.
443 *
444 * @type T Type of object.
445 * @param object Object to test.
446 * @param message Message to display on error.
447 */
448 ok<T>(value: T, message?: string): void;
449
450 /**
451 * Asserts that object is falsy.
452 *
453 * @type T Type of object.
454 * @param object Object to test.
455 * @param message Message to display on error.
456 */
457 isNotOk<T>(value: T, message?: string): void;
458
459 /**
460 * Asserts that object is falsy.
461 *
462 * @type T Type of object.
463 * @param object Object to test.
464 * @param message Message to display on error.
465 */
466 notOk<T>(value: T, message?: string): void;
467
468 /**
469 * Asserts non-strict equality (==) of actual and expected.
470 *
471 * @type T Type of the objects.
472 * @param actual Actual value.
473 * @param expected Potential expected value.
474 * @param message Message to display on error.
475 */
476 equal<T>(actual: T, expected: T, message?: string): void;
477
478 /**
479 * Asserts non-strict inequality (!=) of actual and expected.
480 *
481 * @type T Type of the objects.
482 * @param actual Actual value.
483 * @param expected Potential expected value.
484 * @param message Message to display on error.
485 */
486 notEqual<T>(actual: T, expected: T, message?: string): void;
487
488 /**
489 * Asserts strict equality (===) of actual and expected.
490 *
491 * @type T Type of the objects.
492 * @param actual Actual value.
493 * @param expected Potential expected value.
494 * @param message Message to display on error.
495 */
496 strictEqual<T>(actual: T, expected: T, message?: string): void;
497
498 /**
499 * Asserts strict inequality (!==) of actual and expected.
500 *
501 * @type T Type of the objects.
502 * @param actual Actual value.
503 * @param expected Potential expected value.
504 * @param message Message to display on error.
505 */
506 notStrictEqual<T>(actual: T, expected: T, message?: string): void;
507
508 /**
509 * Asserts that actual is deeply equal to expected.
510 *
511 * @type T Type of the objects.
512 * @param actual Actual value.
513 * @param expected Potential expected value.
514 * @param message Message to display on error.
515 */
516 deepEqual<T>(actual: T, expected: T, message?: string): void;
517
518 /**
519 * Asserts that actual is not deeply equal to expected.
520 *
521 * @type T Type of the objects.
522 * @param actual Actual value.
523 * @param expected Potential expected value.
524 * @param message Message to display on error.
525 */
526 notDeepEqual<T>(actual: T, expected: T, message?: string): void;
527
528 /**
529 * Alias to deepEqual
530 *
531 * @type T Type of the objects.
532 * @param actual Actual value.
533 * @param expected Potential expected value.
534 * @param message Message to display on error.
535 */
536 deepStrictEqual<T>(actual: T, expected: T, message?: string): void;
537
538 /**
539 * Asserts valueToCheck is strictly greater than (>) valueToBeAbove.
540 *
541 * @param valueToCheck Actual value.
542 * @param valueToBeAbove Minimum Potential expected value.
543 * @param message Message to display on error.
544 */
545 isAbove(valueToCheck: number, valueToBeAbove: number, message?: string): void;
546
547 /**
548 * Asserts valueToCheck is greater than or equal to (>=) valueToBeAtLeast.
549 *
550 * @param valueToCheck Actual value.
551 * @param valueToBeAtLeast Minimum Potential expected value.
552 * @param message Message to display on error.
553 */
554 isAtLeast(valueToCheck: number, valueToBeAtLeast: number, message?: string): void;
555
556 /**
557 * Asserts valueToCheck is strictly less than (<) valueToBeBelow.
558 *
559 * @param valueToCheck Actual value.
560 * @param valueToBeBelow Minimum Potential expected value.
561 * @param message Message to display on error.
562 */
563 isBelow(valueToCheck: number, valueToBeBelow: number, message?: string): void;
564
565 /**
566 * Asserts valueToCheck is less than or equal to (<=) valueToBeAtMost.
567 *
568 * @param valueToCheck Actual value.
569 * @param valueToBeAtMost Minimum Potential expected value.
570 * @param message Message to display on error.
571 */
572 isAtMost(valueToCheck: number, valueToBeAtMost: number, message?: string): void;
573
574 /**
575 * Asserts that value is true.
576 *
577 * @type T Type of value.
578 * @param value Actual value.
579 * @param message Message to display on error.
580 */
581 isTrue<T>(value: T, message?: string): void;
582
583 /**
584 * Asserts that value is false.
585 *
586 * @type T Type of value.
587 * @param value Actual value.
588 * @param message Message to display on error.
589 */
590 isFalse<T>(value: T, message?: string): void;
591
592 /**
593 * Asserts that value is not true.
594 *
595 * @type T Type of value.
596 * @param value Actual value.
597 * @param message Message to display on error.
598 */
599 isNotTrue<T>(value: T, message?: string): void;
600
601 /**
602 * Asserts that value is not false.
603 *
604 * @type T Type of value.
605 * @param value Actual value.
606 * @param message Message to display on error.
607 */
608 isNotFalse<T>(value: T, message?: string): void;
609
610 /**
611 * Asserts that value is null.
612 *
613 * @type T Type of value.
614 * @param value Actual value.
615 * @param message Message to display on error.
616 */
617 isNull<T>(value: T, message?: string): void;
618
619 /**
620 * Asserts that value is not null.
621 *
622 * @type T Type of value.
623 * @param value Actual value.
624 * @param message Message to display on error.
625 */
626 isNotNull<T>(value: T, message?: string): void;
627
628 /**
629 * Asserts that value is NaN.
630 *
631 * @type T Type of value.
632 * @param value Actual value.
633 * @param message Message to display on error.
634 */
635 isNaN<T>(value: T, message?: string): void;
636
637 /**
638 * Asserts that value is not NaN.
639 *
640 * @type T Type of value.
641 * @param value Actual value.
642 * @param message Message to display on error.
643 */
644 isNotNaN<T>(value: T, message?: string): void;
645
646 /**
647 * Asserts that the target is neither null nor undefined.
648 *
649 * @type T Type of value.
650 * @param value Actual value.
651 * @param message Message to display on error.
652 */
653 exists<T>(value: T, message?: string): void;
654
655 /**
656 * Asserts that the target is either null or undefined.
657 *
658 * @type T Type of value.
659 * @param value Actual value.
660 * @param message Message to display on error.
661 */
662 notExists<T>(value: T, message?: string): void;
663
664 /**
665 * Asserts that value is undefined.
666 *
667 * @type T Type of value.
668 * @param value Actual value.
669 * @param message Message to display on error.
670 */
671 isUndefined<T>(value: T, message?: string): void;
672
673 /**
674 * Asserts that value is not undefined.
675 *
676 * @type T Type of value.
677 * @param value Actual value.
678 * @param message Message to display on error.
679 */
680 isDefined<T>(value: T, message?: string): void;
681
682 /**
683 * Asserts that value is a function.
684 *
685 * @type T Type of value.
686 * @param value Actual value.
687 * @param message Message to display on error.
688 */
689 isFunction<T>(value: T, message?: string): void;
690
691 /**
692 * Asserts that value is not a function.
693 *
694 * @type T Type of value.
695 * @param value Actual value.
696 * @param message Message to display on error.
697 */
698 isNotFunction<T>(value: T, message?: string): void;
699
700 /**
701 * Asserts that value is an object of type 'Object'
702 * (as revealed by Object.prototype.toString).
703 *
704 * @type T Type of value.
705 * @param value Actual value.
706 * @param message Message to display on error.
707 * @remarks The assertion does not match subclassed objects.
708 */
709 isObject<T>(value: T, message?: string): void;
710
711 /**
712 * Asserts that value is not an object of type 'Object'
713 * (as revealed by Object.prototype.toString).
714 *
715 * @type T Type of value.
716 * @param value Actual value.
717 * @param message Message to display on error.
718 */
719 isNotObject<T>(value: T, message?: string): void;
720
721 /**
722 * Asserts that value is an array.
723 *
724 * @type T Type of value.
725 * @param value Actual value.
726 * @param message Message to display on error.
727 */
728 isArray<T>(value: T, message?: string): void;
729
730 /**
731 * Asserts that value is not an array.
732 *
733 * @type T Type of value.
734 * @param value Actual value.
735 * @param message Message to display on error.
736 */
737 isNotArray<T>(value: T, message?: string): void;
738
739 /**
740 * Asserts that value is a string.
741 *
742 * @type T Type of value.
743 * @param value Actual value.
744 * @param message Message to display on error.
745 */
746 isString<T>(value: T, message?: string): void;
747
748 /**
749 * Asserts that value is not a string.
750 *
751 * @type T Type of value.
752 * @param value Actual value.
753 * @param message Message to display on error.
754 */
755 isNotString<T>(value: T, message?: string): void;
756
757 /**
758 * Asserts that value is a number.
759 *
760 * @type T Type of value.
761 * @param value Actual value.
762 * @param message Message to display on error.
763 */
764 isNumber<T>(value: T, message?: string): void;
765
766 /**
767 * Asserts that value is not a number.
768 *
769 * @type T Type of value.
770 * @param value Actual value.
771 * @param message Message to display on error.
772 */
773 isNotNumber<T>(value: T, message?: string): void;
774
775 /**
776 * Asserts that value is a finite number.
777 * Unlike `.isNumber`, this will fail for `NaN` and `Infinity`.
778 *
779 * @type T Type of value
780 * @param value Actual value
781 * @param message Message to display on error.
782 */
783 isFinite<T>(value: T, message?: string): void;
784
785 /**
786 * Asserts that value is a boolean.
787 *
788 * @type T Type of value.
789 * @param value Actual value.
790 * @param message Message to display on error.
791 */
792 isBoolean<T>(value: T, message?: string): void;
793
794 /**
795 * Asserts that value is not a boolean.
796 *
797 * @type T Type of value.
798 * @param value Actual value.
799 * @param message Message to display on error.
800 */
801 isNotBoolean<T>(value: T, message?: string): void;
802
803 /**
804 * Asserts that value's type is name, as determined by Object.prototype.toString.
805 *
806 * @type T Type of value.
807 * @param value Actual value.
808 * @param name Potential expected type name of value.
809 * @param message Message to display on error.
810 */
811 typeOf<T>(value: T, name: string, message?: string): void;
812
813 /**
814 * Asserts that value's type is not name, as determined by Object.prototype.toString.
815 *
816 * @type T Type of value.
817 * @param value Actual value.
818 * @param name Potential expected type name of value.
819 * @param message Message to display on error.
820 */
821 notTypeOf<T>(value: T, name: string, message?: string): void;
822
823 /**
824 * Asserts that value is an instance of constructor.
825 *
826 * @type T Type of value.
827 * @param value Actual value.
828 * @param constructor Potential expected contructor of value.
829 * @param message Message to display on error.
830 */
831 instanceOf<T>(value: T, constructor: Function, message?: string): void;
832
833 /**
834 * Asserts that value is not an instance of constructor.
835 *
836 * @type T Type of value.
837 * @param value Actual value.
838 * @param constructor Potential expected contructor of value.
839 * @param message Message to display on error.
840 */
841 notInstanceOf<T>(value: T, type: Function, message?: string): void;
842
843 /**
844 * Asserts that haystack includes needle.
845 *
846 * @param haystack Container string.
847 * @param needle Potential substring of haystack.
848 * @param message Message to display on error.
849 */
850 include(haystack: string, needle: string, message?: string): void;
851
852 /**
853 * Asserts that haystack includes needle.
854 *
855 * @type T Type of values in haystack.
856 * @param haystack Container array, set or map.
857 * @param needle Potential value contained in haystack.
858 * @param message Message to display on error.
859 */
860 include<T>(haystack: ReadonlyArray<T> | ReadonlySet<T> | ReadonlyMap<any, T>, needle: T, message?: string): void;
861
862 /**
863 * Asserts that haystack includes needle.
864 *
865 * @type T Type of values in haystack.
866 * @param haystack WeakSet container.
867 * @param needle Potential value contained in haystack.
868 * @param message Message to display on error.
869 */
870 include<T extends object>(haystack: WeakSet<T>, needle: T, message?: string): void;
871
872 /**
873 * Asserts that haystack includes needle.
874 *
875 * @type T Type of haystack.
876 * @param haystack Object.
877 * @param needle Potential subset of the haystack's properties.
878 * @param message Message to display on error.
879 */
880 include<T>(haystack: T, needle: Partial<T>, message?: string): void;
881
882 /**
883 * Asserts that haystack does not includes needle.
884 *
885 * @param haystack Container string.
886 * @param needle Potential substring of haystack.
887 * @param message Message to display on error.
888 */
889 notInclude(haystack: string, needle: string, message?: string): void;
890
891 /**
892 * Asserts that haystack does not includes needle.
893 *
894 * @type T Type of values in haystack.
895 * @param haystack Container array, set or map.
896 * @param needle Potential value contained in haystack.
897 * @param message Message to display on error.
898 */
899 notInclude<T>(haystack: ReadonlyArray<T> | ReadonlySet<T> | ReadonlyMap<any, T>, needle: T, message?: string): void;
900
901 /**
902 * Asserts that haystack does not includes needle.
903 *
904 * @type T Type of values in haystack.
905 * @param haystack WeakSet container.
906 * @param needle Potential value contained in haystack.
907 * @param message Message to display on error.
908 */
909 notInclude<T extends object>(haystack: WeakSet<T>, needle: T, message?: string): void;
910
911 /**
912 * Asserts that haystack does not includes needle.
913 *
914 * @type T Type of haystack.
915 * @param haystack Object.
916 * @param needle Potential subset of the haystack's properties.
917 * @param message Message to display on error.
918 */
919 notInclude<T>(haystack: T, needle: Partial<T>, message?: string): void;
920
921 /**
922 * Asserts that haystack includes needle. Deep equality is used.
923 *
924 * @param haystack Container string.
925 * @param needle Potential substring of haystack.
926 * @param message Message to display on error.
927 *
928 * @deprecated Does not have any effect on string. Use {@link Assert#include} instead.
929 */
930 deepInclude(haystack: string, needle: string, message?: string): void;
931
932 /**
933 * Asserts that haystack includes needle. Deep equality is used.
934 *
935 * @type T Type of values in haystack.
936 * @param haystack Container array, set or map.
937 * @param needle Potential value contained in haystack.
938 * @param message Message to display on error.
939 */
940 deepInclude<T>(haystack: ReadonlyArray<T> | ReadonlySet<T> | ReadonlyMap<any, T>, needle: T, message?: string): void;
941
942 /**
943 * Asserts that haystack does not includes needle.
944 *
945 * @type T Type of haystack.
946 * @param haystack Object.
947 * @param needle Potential subset of the haystack's properties.
948 * @param message Message to display on error.
949 */
950 deepInclude<T>(haystack: T, needle: T extends WeakSet<any> ? never : Partial<T>, message?: string): void;
951
952 /**
953 * Asserts that haystack does not includes needle. Deep equality is used.
954 *
955 * @param haystack Container string.
956 * @param needle Potential substring of haystack.
957 * @param message Message to display on error.
958 *
959 * @deprecated Does not have any effect on string. Use {@link Assert#notInclude} instead.
960 */
961 notDeepInclude(haystack: string, needle: string, message?: string): void;
962
963 /**
964 * Asserts that haystack does not includes needle. Deep equality is used.
965 *
966 * @type T Type of values in haystack.
967 * @param haystack Container array, set or map.
968 * @param needle Potential value contained in haystack.
969 * @param message Message to display on error.
970 */
971 notDeepInclude<T>(haystack: ReadonlyArray<T> | ReadonlySet<T> | ReadonlyMap<any, T>, needle: T, message?: string): void;
972
973 /**
974 * Asserts that haystack does not includes needle. Deep equality is used.
975 *
976 * @type T Type of haystack.
977 * @param haystack Object.
978 * @param needle Potential subset of the haystack's properties.
979 * @param message Message to display on error.
980 */
981 notDeepInclude<T>(haystack: T, needle: T extends WeakSet<any> ? never : Partial<T>, message?: string): void;
982
983 /**
984 * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the inclusion of a subset of properties in an object.
985 *
986 * Enables the use of dot- and bracket-notation for referencing nested properties.
987 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
988 * Can be used to assert the inclusion of a subset of properties in an object.
989 * Enables the use of dot- and bracket-notation for referencing nested properties.
990 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
991 *
992 * @param haystack
993 * @param needle
994 * @param message Message to display on error.
995 */
996 nestedInclude(haystack: any, needle: any, message?: string): void;
997
998 /**
999 * Asserts that ‘haystack’ does not include ‘needle’. Can be used to assert the absence of a subset of properties in an object.
1000 *
1001 * Enables the use of dot- and bracket-notation for referencing nested properties.
1002 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
1003 * Can be used to assert the inclusion of a subset of properties in an object.
1004 * Enables the use of dot- and bracket-notation for referencing nested properties.
1005 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
1006 *
1007 * @param haystack
1008 * @param needle
1009 * @param message Message to display on error.
1010 */
1011 notNestedInclude(haystack: any, needle: any, message?: string): void;
1012
1013 /**
1014 * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the inclusion of a subset of properties in an object while checking for deep equality
1015 *
1016 * Enables the use of dot- and bracket-notation for referencing nested properties.
1017 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
1018 * Can be used to assert the inclusion of a subset of properties in an object.
1019 * Enables the use of dot- and bracket-notation for referencing nested properties.
1020 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
1021 *
1022 * @param haystack
1023 * @param needle
1024 * @param message Message to display on error.
1025 */
1026 deepNestedInclude(haystack: any, needle: any, message?: string): void;
1027
1028 /**
1029 * Asserts that ‘haystack’ does not include ‘needle’. Can be used to assert the absence of a subset of properties in an object while checking for deep equality.
1030 *
1031 * Enables the use of dot- and bracket-notation for referencing nested properties.
1032 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.Asserts that ‘haystack’ includes ‘needle’.
1033 * Can be used to assert the inclusion of a subset of properties in an object.
1034 * Enables the use of dot- and bracket-notation for referencing nested properties.
1035 * ‘[]’ and ‘.’ in property names can be escaped using double backslashes.
1036 *
1037 * @param haystack
1038 * @param needle
1039 * @param message Message to display on error.
1040 */
1041 notDeepNestedInclude(haystack: any, needle: any, message?: string): void;
1042
1043 /**
1044 * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the inclusion of a subset of properties in an object while ignoring inherited properties.
1045 *
1046 * @param haystack
1047 * @param needle
1048 * @param message Message to display on error.
1049 */
1050 ownInclude(haystack: any, needle: any, message?: string): void;
1051
1052 /**
1053 * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the absence of a subset of properties in an object while ignoring inherited properties.
1054 *
1055 * @param haystack
1056 * @param needle
1057 * @param message Message to display on error.
1058 */
1059 notOwnInclude(haystack: any, needle: any, message?: string): void;
1060
1061 /**
1062 * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the inclusion of a subset of properties in an object while ignoring inherited properties and checking for deep
1063 *
1064 * @param haystack
1065 * @param needle
1066 * @param message Message to display on error.
1067 */
1068 deepOwnInclude(haystack: any, needle: any, message?: string): void;
1069
1070 /**
1071 * Asserts that ‘haystack’ includes ‘needle’. Can be used to assert the absence of a subset of properties in an object while ignoring inherited properties and checking for deep equality.
1072 *
1073 * @param haystack
1074 * @param needle
1075 * @param message Message to display on error.
1076 */
1077 notDeepOwnInclude(haystack: any, needle: any, message?: string): void;
1078
1079 /**
1080 * Asserts that value matches the regular expression regexp.
1081 *
1082 * @param value Actual value.
1083 * @param regexp Potential match of value.
1084 * @param message Message to display on error.
1085 */
1086 match(value: string, regexp: RegExp, message?: string): void;
1087
1088 /**
1089 * Asserts that value does not match the regular expression regexp.
1090 *
1091 * @param value Actual value.
1092 * @param regexp Potential match of value.
1093 * @param message Message to display on error.
1094 */
1095 notMatch(expected: any, regexp: RegExp, message?: string): void;
1096
1097 /**
1098 * Asserts that object has a property named by property.
1099 *
1100 * @type T Type of object.
1101 * @param object Container object.
1102 * @param property Potential contained property of object.
1103 * @param message Message to display on error.
1104 */
1105 property<T>(object: T, property: string /* keyof T */, message?: string): void;
1106
1107 /**
1108 * Asserts that object has a property named by property.
1109 *
1110 * @type T Type of object.
1111 * @param object Container object.
1112 * @param property Potential contained property of object.
1113 * @param message Message to display on error.
1114 */
1115 notProperty<T>(object: T, property: string /* keyof T */, message?: string): void;
1116
1117 /**
1118 * Asserts that object has a property named by property, which can be a string
1119 * using dot- and bracket-notation for deep reference.
1120 *
1121 * @type T Type of object.
1122 * @param object Container object.
1123 * @param property Potential contained property of object.
1124 * @param message Message to display on error.
1125 */
1126 deepProperty<T>(object: T, property: string, message?: string): void;
1127
1128 /**
1129 * Asserts that object does not have a property named by property, which can be a
1130 * string using dot- and bracket-notation for deep reference.
1131 *
1132 * @type T Type of object.
1133 * @param object Container object.
1134 * @param property Potential contained property of object.
1135 * @param message Message to display on error.
1136 */
1137 notDeepProperty<T>(object: T, property: string, message?: string): void;
1138
1139 /**
1140 * Asserts that object has a property named by property with value given by value.
1141 *
1142 * @type T Type of object.
1143 * @type V Type of value.
1144 * @param object Container object.
1145 * @param property Potential contained property of object.
1146 * @param value Potential expected property value.
1147 * @param message Message to display on error.
1148 */
1149 propertyVal<T, V>(object: T, property: string /* keyof T */, value: V, message?: string): void;
1150
1151 /**
1152 * Asserts that object has a property named by property with value given by value.
1153 *
1154 * @type T Type of object.
1155 * @type V Type of value.
1156 * @param object Container object.
1157 * @param property Potential contained property of object.
1158 * @param value Potential expected property value.
1159 * @param message Message to display on error.
1160 */
1161 notPropertyVal<T, V>(object: T, property: string /* keyof T */, value: V, message?: string): void;
1162
1163 /**
1164 * Asserts that object has a property named by property, which can be a string
1165 * using dot- and bracket-notation for deep reference.
1166 *
1167 * @type T Type of object.
1168 * @type V Type of value.
1169 * @param object Container object.
1170 * @param property Potential contained property of object.
1171 * @param value Potential expected property value.
1172 * @param message Message to display on error.
1173 */
1174 deepPropertyVal<T, V>(object: T, property: string, value: V, message?: string): void;
1175
1176 /**
1177 * Asserts that object does not have a property named by property, which can be a
1178 * string using dot- and bracket-notation for deep reference.
1179 *
1180 * @type T Type of object.
1181 * @type V Type of value.
1182 * @param object Container object.
1183 * @param property Potential contained property of object.
1184 * @param value Potential expected property value.
1185 * @param message Message to display on error.
1186 */
1187 notDeepPropertyVal<T, V>(object: T, property: string, value: V, message?: string): void;
1188
1189 /**
1190 * Asserts that object has a length property with the expected value.
1191 *
1192 * @type T Type of object.
1193 * @param object Container object.
1194 * @param length Potential expected length of object.
1195 * @param message Message to display on error.
1196 */
1197 lengthOf<T extends { readonly length?: number | undefined }>(object: T, length: number, message?: string): void;
1198
1199 /**
1200 * Asserts that fn will throw an error.
1201 *
1202 * @param fn Function that may throw.
1203 * @param errMsgMatcher Expected error message matcher.
1204 * @param ignored Ignored parameter.
1205 * @param message Message to display on error.
1206 */
1207 throw(fn: () => void, errMsgMatcher?: RegExp | string, ignored?: any, message?: string): void;
1208
1209 /**
1210 * Asserts that fn will throw an error.
1211 *
1212 * @param fn Function that may throw.
1213 * @param errorLike Expected error constructor or error instance.
1214 * @param errMsgMatcher Expected error message matcher.
1215 * @param message Message to display on error.
1216 */
1217 throw(
1218 fn: () => void,
1219 errorLike?: ErrorConstructor | Error | null,
1220 errMsgMatcher?: RegExp | string | null,
1221 message?: string,
1222 ): void;
1223
1224 /**
1225 * Asserts that fn will throw an error.
1226 *
1227 * @param fn Function that may throw.
1228 * @param errMsgMatcher Expected error message matcher.
1229 * @param ignored Ignored parameter.
1230 * @param message Message to display on error.
1231 */
1232 throws(fn: () => void, errMsgMatcher?: RegExp | string, ignored?: any, message?: string): void;
1233
1234 /**
1235 * Asserts that fn will throw an error.
1236 *
1237 * @param fn Function that may throw.
1238 * @param errorLike Expected error constructor or error instance.
1239 * @param errMsgMatcher Expected error message matcher.
1240 * @param message Message to display on error.
1241 */
1242 throws(
1243 fn: () => void,
1244 errorLike?: ErrorConstructor | Error | null,
1245 errMsgMatcher?: RegExp | string | null,
1246 message?: string,
1247 ): void;
1248
1249 /**
1250 * Asserts that fn will throw an error.
1251 *
1252 * @param fn Function that may throw.
1253 * @param errMsgMatcher Expected error message matcher.
1254 * @param ignored Ignored parameter.
1255 * @param message Message to display on error.
1256 */
1257 Throw(fn: () => void, errMsgMatcher?: RegExp | string, ignored?: any, message?: string): void;
1258
1259 /**
1260 * Asserts that fn will throw an error.
1261 *
1262 * @param fn Function that may throw.
1263 * @param errorLike Expected error constructor or error instance.
1264 * @param errMsgMatcher Expected error message matcher.
1265 * @param message Message to display on error.
1266 */
1267 Throw(
1268 fn: () => void,
1269 errorLike?: ErrorConstructor | Error | null,
1270 errMsgMatcher?: RegExp | string | null,
1271 message?: string,
1272 ): void;
1273
1274 /**
1275 * Asserts that fn will not throw an error.
1276 *
1277 * @param fn Function that may throw.
1278 * @param errMsgMatcher Expected error message matcher.
1279 * @param ignored Ignored parameter.
1280 * @param message Message to display on error.
1281 */
1282 doesNotThrow(fn: () => void, errMsgMatcher?: RegExp | string, ignored?: any, message?: string): void;
1283
1284 /**
1285 * Asserts that fn will not throw an error.
1286 *
1287 * @param fn Function that may throw.
1288 * @param errorLike Expected error constructor or error instance.
1289 * @param errMsgMatcher Expected error message matcher.
1290 * @param message Message to display on error.
1291 */
1292 doesNotThrow(
1293 fn: () => void,
1294 errorLike?: ErrorConstructor | Error | null,
1295 errMsgMatcher?: RegExp | string | null,
1296 message?: string,
1297 ): void;
1298
1299 /**
1300 * Compares two values using operator.
1301 *
1302 * @param val1 Left value during comparison.
1303 * @param operator Comparison operator.
1304 * @param val2 Right value during comparison.
1305 * @param message Message to display on error.
1306 */
1307 operator(val1: OperatorComparable, operator: Operator, val2: OperatorComparable, message?: string): void;
1308
1309 /**
1310 * Asserts that the target is equal to expected, to within a +/- delta range.
1311 *
1312 * @param actual Actual value
1313 * @param expected Potential expected value.
1314 * @param delta Maximum differenced between values.
1315 * @param message Message to display on error.
1316 */
1317 closeTo(actual: number, expected: number, delta: number, message?: string): void;
1318
1319 /**
1320 * Asserts that the target is equal to expected, to within a +/- delta range.
1321 *
1322 * @param actual Actual value
1323 * @param expected Potential expected value.
1324 * @param delta Maximum differenced between values.
1325 * @param message Message to display on error.
1326 */
1327 approximately(act: number, exp: number, delta: number, message?: string): void;
1328
1329 /**
1330 * Asserts that set1 and set2 have the same members. Order is not take into account.
1331 *
1332 * @type T Type of set values.
1333 * @param set1 Actual set of values.
1334 * @param set2 Potential expected set of values.
1335 * @param message Message to display on error.
1336 */
1337 sameMembers<T>(set1: T[], set2: T[], message?: string): void;
1338
1339 /**
1340 * Asserts that set1 and set2 have the same members using deep equality checking.
1341 * Order is not take into account.
1342 *
1343 * @type T Type of set values.
1344 * @param set1 Actual set of values.
1345 * @param set2 Potential expected set of values.
1346 * @param message Message to display on error.
1347 */
1348 sameDeepMembers<T>(set1: T[], set2: T[], message?: string): void;
1349
1350 /**
1351 * Asserts that set1 and set2 have the same members in the same order.
1352 * Uses a strict equality check (===).
1353 *
1354 * @type T Type of set values.
1355 * @param set1 Actual set of values.
1356 * @param set2 Potential expected set of values.
1357 * @param message Message to display on error.
1358 */
1359 sameOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
1360
1361 /**
1362 * Asserts that set1 and set2 dont have the same members in the same order.
1363 * Uses a strict equality check (===).
1364 *
1365 * @type T Type of set values.
1366 * @param set1 Actual set of values.
1367 * @param set2 Potential expected set of values.
1368 * @param message Message to display on error.
1369 */
1370 notSameOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
1371
1372 /**
1373 * Asserts that set1 and set2 have the same members in the same order.
1374 * Uses a deep equality check.
1375 *
1376 * @type T Type of set values.
1377 * @param set1 Actual set of values.
1378 * @param set2 Potential expected set of values.
1379 * @param message Message to display on error.
1380 */
1381 sameDeepOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
1382
1383 /**
1384 * Asserts that set1 and set2 dont have the same members in the same order.
1385 * Uses a deep equality check.
1386 *
1387 * @type T Type of set values.
1388 * @param set1 Actual set of values.
1389 * @param set2 Potential expected set of values.
1390 * @param message Message to display on error.
1391 */
1392 notSameDeepOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
1393
1394 /**
1395 * Asserts that subset is included in superset in the same order beginning with the first element in superset.
1396 * Uses a strict equality check (===).
1397 *
1398 * @type T Type of set values.
1399 * @param superset Actual set of values.
1400 * @param subset Potential contained set of values.
1401 * @param message Message to display on error.
1402 */
1403 includeOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
1404
1405 /**
1406 * Asserts that subset isnt included in superset in the same order beginning with the first element in superset.
1407 * Uses a strict equality check (===).
1408 *
1409 * @type T Type of set values.
1410 * @param superset Actual set of values.
1411 * @param subset Potential contained set of values.
1412 * @param message Message to display on error.
1413 */
1414 notIncludeOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
1415
1416 /**
1417 * Asserts that subset is included in superset in the same order beginning with the first element in superset.
1418 * Uses a deep equality check.
1419 *
1420 * @type T Type of set values.
1421 * @param superset Actual set of values.
1422 * @param subset Potential contained set of values.
1423 * @param message Message to display on error.
1424 */
1425 includeDeepOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
1426
1427 /**
1428 * Asserts that subset isnt included in superset in the same order beginning with the first element in superset.
1429 * Uses a deep equality check.
1430 *
1431 * @type T Type of set values.
1432 * @param superset Actual set of values.
1433 * @param subset Potential contained set of values.
1434 * @param message Message to display on error.
1435 */
1436 notIncludeDeepOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
1437
1438 /**
1439 * Asserts that subset is included in superset. Order is not take into account.
1440 *
1441 * @type T Type of set values.
1442 * @param superset Actual set of values.
1443 * @param subset Potential contained set of values.
1444 * @param message Message to display on error.
1445 */
1446 includeMembers<T>(superset: T[], subset: T[], message?: string): void;
1447
1448 /**
1449 * Asserts that subset isnt included in superset in any order.
1450 * Uses a strict equality check (===). Duplicates are ignored.
1451 *
1452 * @type T Type of set values.
1453 * @param superset Actual set of values.
1454 * @param subset Potential not contained set of values.
1455 * @param message Message to display on error.
1456 */
1457 notIncludeMembers<T>(superset: T[], subset: T[], message?: string): void;
1458
1459 /**
1460 * Asserts that subset is included in superset using deep equality checking.
1461 * Order is not take into account.
1462 *
1463 * @type T Type of set values.
1464 * @param superset Actual set of values.
1465 * @param subset Potential contained set of values.
1466 * @param message Message to display on error.
1467 */
1468 includeDeepMembers<T>(superset: T[], subset: T[], message?: string): void;
1469
1470 /**
1471 * Asserts that non-object, non-array value inList appears in the flat array list.
1472 *
1473 * @type T Type of list values.
1474 * @param inList Value expected to be in the list.
1475 * @param list List of values.
1476 * @param message Message to display on error.
1477 */
1478 oneOf<T>(inList: T, list: T[], message?: string): void;
1479
1480 /**
1481 * Asserts that a function changes the value of a property.
1482 *
1483 * @type T Type of object.
1484 * @param modifier Function to run.
1485 * @param object Container object.
1486 * @param property Property of object expected to be modified.
1487 * @param message Message to display on error.
1488 */
1489 changes<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
1490
1491 /**
1492 * Asserts that a function does not change the value of a property.
1493 *
1494 * @type T Type of object.
1495 * @param modifier Function to run.
1496 * @param object Container object.
1497 * @param property Property of object expected not to be modified.
1498 * @param message Message to display on error.
1499 */
1500 doesNotChange<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
1501
1502 /**
1503 * Asserts that a function increases an object property.
1504 *
1505 * @type T Type of object.
1506 * @param modifier Function to run.
1507 * @param object Container object.
1508 * @param property Property of object expected to be increased.
1509 * @param message Message to display on error.
1510 */
1511 increases<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
1512
1513 /**
1514 * Asserts that a function does not increase an object property.
1515 *
1516 * @type T Type of object.
1517 * @param modifier Function to run.
1518 * @param object Container object.
1519 * @param property Property of object expected not to be increased.
1520 * @param message Message to display on error.
1521 */
1522 doesNotIncrease<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
1523
1524 /**
1525 * Asserts that a function decreases an object property.
1526 *
1527 * @type T Type of object.
1528 * @param modifier Function to run.
1529 * @param object Container object.
1530 * @param property Property of object expected to be decreased.
1531 * @param message Message to display on error.
1532 */
1533 decreases<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
1534
1535 /**
1536 * Asserts that a function does not decrease an object property.
1537 *
1538 * @type T Type of object.
1539 * @param modifier Function to run.
1540 * @param object Container object.
1541 * @param property Property of object expected not to be decreased.
1542 * @param message Message to display on error.
1543 */
1544 doesNotDecrease<T>(modifier: Function, object: T, property: string /* keyof T */, message?: string): void;
1545
1546 /**
1547 * Asserts if value is not a false value, and throws if it is a true value.
1548 *
1549 * @type T Type of object.
1550 * @param object Actual value.
1551 * @param message Message to display on error.
1552 * @remarks This is added to allow for chai to be a drop-in replacement for
1553 * Nodes assert class.
1554 */
1555 ifError<T>(object: T, message?: string): void;
1556
1557 /**
1558 * Asserts that object is extensible (can have new properties added to it).
1559 *
1560 * @type T Type of object
1561 * @param object Actual value.
1562 * @param message Message to display on error.
1563 */
1564 isExtensible<T>(object: T, message?: string): void;
1565
1566 /**
1567 * Asserts that object is extensible (can have new properties added to it).
1568 *
1569 * @type T Type of object
1570 * @param object Actual value.
1571 * @param message Message to display on error.
1572 */
1573 extensible<T>(object: T, message?: string): void;
1574
1575 /**
1576 * Asserts that object is not extensible.
1577 *
1578 * @type T Type of object
1579 * @param object Actual value.
1580 * @param message Message to display on error.
1581 */
1582 isNotExtensible<T>(object: T, message?: string): void;
1583
1584 /**
1585 * Asserts that object is not extensible.
1586 *
1587 * @type T Type of object
1588 * @param object Actual value.
1589 * @param message Message to display on error.
1590 */
1591 notExtensible<T>(object: T, message?: string): void;
1592
1593 /**
1594 * Asserts that object is sealed (can have new properties added to it
1595 * and its existing properties cannot be removed).
1596 *
1597 * @type T Type of object
1598 * @param object Actual value.
1599 * @param message Message to display on error.
1600 */
1601 isSealed<T>(object: T, message?: string): void;
1602
1603 /**
1604 * Asserts that object is sealed (can have new properties added to it
1605 * and its existing properties cannot be removed).
1606 *
1607 * @type T Type of object
1608 * @param object Actual value.
1609 * @param message Message to display on error.
1610 */
1611 sealed<T>(object: T, message?: string): void;
1612
1613 /**
1614 * Asserts that object is not sealed.
1615 *
1616 * @type T Type of object
1617 * @param object Actual value.
1618 * @param message Message to display on error.
1619 */
1620 isNotSealed<T>(object: T, message?: string): void;
1621
1622 /**
1623 * Asserts that object is not sealed.
1624 *
1625 * @type T Type of object
1626 * @param object Actual value.
1627 * @param message Message to display on error.
1628 */
1629 notSealed<T>(object: T, message?: string): void;
1630
1631 /**
1632 * Asserts that object is frozen (cannot have new properties added to it
1633 * and its existing properties cannot be removed).
1634 *
1635 * @type T Type of object
1636 * @param object Actual value.
1637 * @param message Message to display on error.
1638 */
1639 isFrozen<T>(object: T, message?: string): void;
1640
1641 /**
1642 * Asserts that object is frozen (cannot have new properties added to it
1643 * and its existing properties cannot be removed).
1644 *
1645 * @type T Type of object
1646 * @param object Actual value.
1647 * @param message Message to display on error.
1648 */
1649 frozen<T>(object: T, message?: string): void;
1650
1651 /**
1652 * Asserts that object is not frozen (cannot have new properties added to it
1653 * and its existing properties cannot be removed).
1654 *
1655 * @type T Type of object
1656 * @param object Actual value.
1657 * @param message Message to display on error.
1658 */
1659 isNotFrozen<T>(object: T, message?: string): void;
1660
1661 /**
1662 * Asserts that object is not frozen (cannot have new properties added to it
1663 * and its existing properties cannot be removed).
1664 *
1665 * @type T Type of object
1666 * @param object Actual value.
1667 * @param message Message to display on error.
1668 */
1669 notFrozen<T>(object: T, message?: string): void;
1670
1671 /**
1672 * Asserts that the target does not contain any values. For arrays and
1673 * strings, it checks the length property. For Map and Set instances, it
1674 * checks the size property. For non-function objects, it gets the count
1675 * of own enumerable string keys.
1676 *
1677 * @type T Type of object
1678 * @param object Actual value.
1679 * @param message Message to display on error.
1680 */
1681 isEmpty<T>(object: T, message?: string): void;
1682
1683 /**
1684 * Asserts that the target contains values. For arrays and strings, it checks
1685 * the length property. For Map and Set instances, it checks the size property.
1686 * For non-function objects, it gets the count of own enumerable string keys.
1687 *
1688 * @type T Type of object.
1689 * @param object Object to test.
1690 * @param message Message to display on error.
1691 */
1692 isNotEmpty<T>(object: T, message?: string): void;
1693
1694 /**
1695 * Asserts that `object` has at least one of the `keys` provided.
1696 * You can also provide a single object instead of a `keys` array and its keys
1697 * will be used as the expected set of keys.
1698 *
1699 * @type T Type of object.
1700 * @param object Object to test.
1701 * @param keys Keys to check
1702 * @param message Message to display on error.
1703 */
1704 hasAnyKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1705
1706 /**
1707 * Asserts that `object` has all and only all of the `keys` provided.
1708 * You can also provide a single object instead of a `keys` array and its keys
1709 * will be used as the expected set of keys.
1710 *
1711 * @type T Type of object.
1712 * @param object Object to test.
1713 * @param keys Keys to check
1714 * @param message Message to display on error.
1715 */
1716 hasAllKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1717
1718 /**
1719 * Asserts that `object` has all of the `keys` provided but may have more keys not listed.
1720 * You can also provide a single object instead of a `keys` array and its keys
1721 * will be used as the expected set of keys.
1722 *
1723 * @type T Type of object.
1724 * @param object Object to test.
1725 * @param keys Keys to check
1726 * @param message Message to display on error.
1727 */
1728 containsAllKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1729
1730 /**
1731 * Asserts that `object` has none of the `keys` provided.
1732 * You can also provide a single object instead of a `keys` array and its keys
1733 * will be used as the expected set of keys.
1734 *
1735 * @type T Type of object.
1736 * @param object Object to test.
1737 * @param keys Keys to check
1738 * @param message Message to display on error.
1739 */
1740 doesNotHaveAnyKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1741
1742 /**
1743 * Asserts that `object` does not have at least one of the `keys` provided.
1744 * You can also provide a single object instead of a `keys` array and its keys
1745 * will be used as the expected set of keys.
1746 *
1747 * @type T Type of object.
1748 * @param object Object to test.
1749 * @param keys Keys to check
1750 * @param message Message to display on error.
1751 */
1752 doesNotHaveAllKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1753
1754 /**
1755 * Asserts that `object` has at least one of the `keys` provided.
1756 * Since Sets and Maps can have objects as keys you can use this assertion to perform
1757 * a deep comparison.
1758 * You can also provide a single object instead of a `keys` array and its keys
1759 * will be used as the expected set of keys.
1760 *
1761 * @type T Type of object.
1762 * @param object Object to test.
1763 * @param keys Keys to check
1764 * @param message Message to display on error.
1765 */
1766 hasAnyDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1767
1768 /**
1769 * Asserts that `object` has all and only all of the `keys` provided.
1770 * Since Sets and Maps can have objects as keys you can use this assertion to perform
1771 * a deep comparison.
1772 * You can also provide a single object instead of a `keys` array and its keys
1773 * will be used as the expected set of keys.
1774 *
1775 * @type T Type of object.
1776 * @param object Object to test.
1777 * @param keys Keys to check
1778 * @param message Message to display on error.
1779 */
1780 hasAllDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1781
1782 /**
1783 * Asserts that `object` contains all of the `keys` provided.
1784 * Since Sets and Maps can have objects as keys you can use this assertion to perform
1785 * a deep comparison.
1786 * You can also provide a single object instead of a `keys` array and its keys
1787 * will be used as the expected set of keys.
1788 *
1789 * @type T Type of object.
1790 * @param object Object to test.
1791 * @param keys Keys to check
1792 * @param message Message to display on error.
1793 */
1794 containsAllDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1795
1796 /**
1797 * Asserts that `object` contains all of the `keys` provided.
1798 * Since Sets and Maps can have objects as keys you can use this assertion to perform
1799 * a deep comparison.
1800 * You can also provide a single object instead of a `keys` array and its keys
1801 * will be used as the expected set of keys.
1802 *
1803 * @type T Type of object.
1804 * @param object Object to test.
1805 * @param keys Keys to check
1806 * @param message Message to display on error.
1807 */
1808 doesNotHaveAnyDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1809
1810 /**
1811 * Asserts that `object` contains all of the `keys` provided.
1812 * Since Sets and Maps can have objects as keys you can use this assertion to perform
1813 * a deep comparison.
1814 * You can also provide a single object instead of a `keys` array and its keys
1815 * will be used as the expected set of keys.
1816 *
1817 * @type T Type of object.
1818 * @param object Object to test.
1819 * @param keys Keys to check
1820 * @param message Message to display on error.
1821 */
1822 doesNotHaveAllDeepKeys<T>(object: T, keys: Array<Object | string> | { [key: string]: any }, message?: string): void;
1823
1824 /**
1825 * Asserts that object has a direct or inherited property named by property,
1826 * which can be a string using dot- and bracket-notation for nested reference.
1827 *
1828 * @type T Type of object.
1829 * @param object Object to test.
1830 * @param property Property to test.
1831 * @param message Message to display on error.
1832 */
1833 nestedProperty<T>(object: T, property: string, message?: string): void;
1834
1835 /**
1836 * Asserts that object does not have a property named by property,
1837 * which can be a string using dot- and bracket-notation for nested reference.
1838 * The property cannot exist on the object nor anywhere in its prototype chain.
1839 *
1840 * @type T Type of object.
1841 * @param object Object to test.
1842 * @param property Property to test.
1843 * @param message Message to display on error.
1844 */
1845 notNestedProperty<T>(object: T, property: string, message?: string): void;
1846
1847 /**
1848 * Asserts that object has a property named by property with value given by value.
1849 * property can use dot- and bracket-notation for nested reference. Uses a strict equality check (===).
1850 *
1851 * @type T Type of object.
1852 * @param object Object to test.
1853 * @param property Property to test.
1854 * @param value Value to test.
1855 * @param message Message to display on error.
1856 */
1857 nestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
1858
1859 /**
1860 * Asserts that object does not have a property named by property with value given by value.
1861 * property can use dot- and bracket-notation for nested reference. Uses a strict equality check (===).
1862 *
1863 * @type T Type of object.
1864 * @param object Object to test.
1865 * @param property Property to test.
1866 * @param value Value to test.
1867 * @param message Message to display on error.
1868 */
1869 notNestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
1870
1871 /**
1872 * Asserts that object has a property named by property with a value given by value.
1873 * property can use dot- and bracket-notation for nested reference. Uses a deep equality check.
1874 *
1875 * @type T Type of object.
1876 * @param object Object to test.
1877 * @param property Property to test.
1878 * @param value Value to test.
1879 * @param message Message to display on error.
1880 */
1881 deepNestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
1882
1883 /**
1884 * Asserts that object does not have a property named by property with value given by value.
1885 * property can use dot- and bracket-notation for nested reference. Uses a deep equality check.
1886 *
1887 * @type T Type of object.
1888 * @param object Object to test.
1889 * @param property Property to test.
1890 * @param value Value to test.
1891 * @param message Message to display on error.
1892 */
1893 notDeepNestedPropertyVal<T>(object: T, property: string, value: any, message?: string): void;
1894 }
1895
1896 export interface Config {
1897 /**
1898 * Default: false
1899 */
1900 includeStack: boolean;
1901
1902 /**
1903 * Default: true
1904 */
1905 showDiff: boolean;
1906
1907 /**
1908 * Default: 40
1909 */
1910 truncateThreshold: number;
1911
1912 /**
1913 * Default: true
1914 */
1915 useProxy: boolean;
1916
1917 /**
1918 * Default: ['then', 'catch', 'inspect', 'toJSON']
1919 */
1920 proxyExcludedKeys: string[];
1921 }
1922
1923 export class AssertionError {
1924 constructor(message: string, _props?: any, ssf?: Function);
1925 name: string;
1926 message: string;
1927 showDiff: boolean;
1928 stack: string;
1929 }
1930}
1931
1932declare const chai: Chai.ChaiStatic;
1933
1934declare module "chai" {
1935 export = chai;
1936}
1937
1938interface Object {
1939 should: Chai.Assertion;
1940}
1941
\No newline at end of file