UNPKG

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