UNPKG

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