UNPKG

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