1- // flow-typed signature: ad251f3a3446f6ab4e6691a94e701cad
2- // flow-typed version: caa120caaa /jest_v23.x.x/flow_>=v0.39.x
1+ // flow-typed signature: 78c200acffbcc16bba9478f5396c3a00
2+ // flow-typed version: b2980740dd /jest_v23.x.x/flow_>=v0.39.x
33
44type JestMockFn < TArguments : $ReadOnlyArray < * > , TReturn > = {
55 ( ...args : TArguments ) : TReturn ,
@@ -17,7 +17,12 @@ type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
1717 * An array that contains all the object instances that have been
1818 * instantiated from this mock function.
1919 */
20- instances : Array < TReturn >
20+ instances : Array < TReturn > ,
21+ /**
22+ * An array that contains all the object results that have been
23+ * returned by this mock function call
24+ */
25+ results : Array < { isThrow : boolean , value : TReturn } >
2126 } ,
2227 /**
2328 * Resets all information stored in the mockFn.mock.calls and
@@ -119,7 +124,9 @@ type JestMatcherResult = {
119124 pass : boolean
120125} ;
121126
122- type JestMatcher = ( actual : any , expected : any ) => JestMatcherResult ;
127+ type JestMatcher = ( actual : any , expected : any ) =>
128+ | JestMatcherResult
129+ | Promise < JestMatcherResult > ;
123130
124131type JestPromiseType = {
125132 /**
@@ -168,11 +175,16 @@ type JestStyledComponentsMatchersType = {
168175 * Plugin: jest-enzyme
169176 */
170177type EnzymeMatchersType = {
178+ // 5.x
179+ toBeEmpty ( ) : void ,
180+ toBePresent ( ) : void ,
181+ // 6.x
171182 toBeChecked ( ) : void ,
172183 toBeDisabled ( ) : void ,
173- toBeEmpty ( ) : void ,
174184 toBeEmptyRender ( ) : void ,
175- toBePresent ( ) : void ,
185+ toContainMatchingElement ( selector : string ) : void ;
186+ toContainMatchingElements ( n : number , selector : string ) : void ;
187+ toContainExactlyOneMatchingElement ( selector : string ) : void ;
176188 toContainReact ( element : React$Element < any > ) : void ,
177189 toExist ( ) : void ,
178190 toHaveClassName ( className : string ) : void ,
@@ -183,17 +195,32 @@ type EnzymeMatchersType = {
183195 toHaveStyle : ( ( styleKey : string , styleValue ? : any ) => void ) & ( ( style : Object ) => void ) ,
184196 toHaveTagName ( tagName : string ) : void ,
185197 toHaveText ( text : string ) : void ,
186- toIncludeText ( text : string ) : void ,
187198 toHaveValue ( value : any ) : void ,
188- toMatchElement ( element : React$Element < any > ) : void ,
189- toMatchSelector ( selector : string ) : void
199+ toIncludeText ( text : string ) : void ,
200+ toMatchElement (
201+ element : React$Element < any > ,
202+ options ?: { | ignoreProps ?: boolean , verbose ?: boolean | } ,
203+ ) : void ,
204+ toMatchSelector ( selector : string ) : void ,
205+ // 7.x
206+ toHaveDisplayName ( name : string ) : void ,
190207} ;
191208
192209// DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers
193210type DomTestingLibraryType = {
211+ toBeDisabled ( ) : void ,
212+ toBeEmpty ( ) : void ,
213+ toBeInTheDocument ( ) : void ,
214+ toBeVisible ( ) : void ,
215+ toContainElement ( element : HTMLElement | null ) : void ,
216+ toContainHTML ( htmlText : string ) : void ,
217+ toHaveAttribute ( name : string , expectedValue ? : string ) : void ,
218+ toHaveClass ( ...classNames : string [ ] ) : void ,
219+ toHaveFocus ( ) : void ,
220+ toHaveFormValues ( expectedValues : { [ name : string ] : any } ) : void ,
221+ toHaveStyle ( css : string ) : void ,
222+ toHaveTextContent ( content : string | RegExp , options ? : { normalizeWhitespace : boolean } ) : void ,
194223 toBeInTheDOM ( ) : void ,
195- toHaveTextContent ( content : string ) : void ,
196- toHaveAttribute ( name : string , expectedValue ? : string ) : void
197224} ;
198225
199226// Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers
@@ -689,11 +716,14 @@ interface JestExpectType {
689716 /**
690717 * This ensures that an Object matches the most recent snapshot.
691718 */
692- toMatchSnapshot ( propertyMatchers ?: { [ key : string ] : JestAsymmetricEqualityType } , name ?: string ) : void ,
719+ toMatchSnapshot ( propertyMatchers ? : any , name ? : string ) : void ,
693720 /**
694721 * This ensures that an Object matches the most recent snapshot.
695722 */
696723 toMatchSnapshot ( name : string ) : void ,
724+
725+ toMatchInlineSnapshot ( snapshot ? : string ) : void ,
726+ toMatchInlineSnapshot ( propertyMatchers ? : any , snapshot ? : string ) : void ,
697727 /**
698728 * Use .toThrow to test that a function throws when it is called.
699729 * If you want to test that a specific error gets thrown, you can provide an
@@ -708,7 +738,8 @@ interface JestExpectType {
708738 * Use .toThrowErrorMatchingSnapshot to test that a function throws a error
709739 * matching the most recent snapshot when it is called.
710740 */
711- toThrowErrorMatchingSnapshot ( ) : void
741+ toThrowErrorMatchingSnapshot ( ) : void ,
742+ toThrowErrorMatchingInlineSnapshot ( snapshot ? : string ) : void ,
712743}
713744
714745type JestObjectType = {
@@ -910,7 +941,20 @@ declare var describe: {
910941 /**
911942 * Skip running this describe block
912943 */
913- skip ( name : JestTestName , fn : ( ) = > void ) : void
944+ skip ( name : JestTestName , fn : ( ) = > void ) : void ,
945+
946+ /**
947+ * each runs this test against array of argument arrays per each run
948+ *
949+ * @param {table } table of Test
950+ */
951+ each (
952+ ...table : Array < Array < mixed > | mixed > | [ Array < string > , string ]
953+ ) : (
954+ name : JestTestName ,
955+ fn ?: ( ...args : Array < any > ) => ?Promise < mixed > ,
956+ timeout ?: number
957+ ) => void ,
914958} ;
915959
916960/** An individual test unit */
@@ -927,17 +971,7 @@ declare var it: {
927971 fn ?: ( done : ( ) => void ) => ?Promise < mixed > ,
928972 timeout ?: number
929973 ) : void ,
930- /**
931- * each runs this test against array of argument arrays per each run
932- *
933- * @param {table } table of Test
934- */
935- each (
936- table : Array < Array < mixed >>
937- ) : (
938- name : JestTestName ,
939- fn ?: ( ...args : Array < any > ) => ?Promise < mixed >
940- ) => void ,
974+
941975 /**
942976 * Only run this test
943977 *
@@ -951,12 +985,14 @@ declare var it: {
951985 timeout ?: number
952986 ) : {
953987 each (
954- table : Array < Array < mixed >>
988+ ... table : Array < Array < mixed > | mixed > | [ Array < string > , string ]
955989 ) : (
956990 name : JestTestName ,
957- fn ?: ( ...args : Array < any > ) => ?Promise < mixed >
991+ fn ?: ( ...args : Array < any > ) => ?Promise < mixed > ,
992+ timeout ?: number
958993 ) => void ,
959994 } ,
995+
960996 /**
961997 * Skip running this test
962998 *
@@ -969,6 +1005,7 @@ declare var it: {
9691005 fn ?: ( done : ( ) => void ) => ?Promise < mixed > ,
9701006 timeout ? : number
9711007 ) : void ,
1008+
9721009 /**
9731010 * Run the test concurrently
9741011 *
@@ -980,8 +1017,22 @@ declare var it: {
9801017 name : JestTestName ,
9811018 fn ?: ( done : ( ) => void ) => ?Promise < mixed > ,
9821019 timeout ? : number
983- ) : void
1020+ ) : void ,
1021+
1022+ /**
1023+ * each runs this test against array of argument arrays per each run
1024+ *
1025+ * @param {table } table of Test
1026+ */
1027+ each (
1028+ ...table : Array < Array < mixed > | mixed > | [ Array < string > , string ]
1029+ ) : (
1030+ name : JestTestName ,
1031+ fn ?: ( ...args : Array < any > ) => ?Promise < mixed > ,
1032+ timeout ?: number
1033+ ) = > void ,
9841034} ;
1035+
9851036declare function fit (
9861037 name : JestTestName ,
9871038 fn : ( done : ( ) = > void ) => ?Promise < mixed > ,
0 commit comments