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
3
3
4
4
type JestMockFn < TArguments : $ReadOnlyArray < * > , TReturn > = {
5
5
( ...args : TArguments ) : TReturn ,
@@ -17,7 +17,12 @@ type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
17
17
* An array that contains all the object instances that have been
18
18
* instantiated from this mock function.
19
19
*/
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 } >
21
26
} ,
22
27
/**
23
28
* Resets all information stored in the mockFn.mock.calls and
@@ -119,7 +124,9 @@ type JestMatcherResult = {
119
124
pass : boolean
120
125
} ;
121
126
122
- type JestMatcher = ( actual : any , expected : any ) => JestMatcherResult ;
127
+ type JestMatcher = ( actual : any , expected : any ) =>
128
+ | JestMatcherResult
129
+ | Promise < JestMatcherResult > ;
123
130
124
131
type JestPromiseType = {
125
132
/**
@@ -168,11 +175,16 @@ type JestStyledComponentsMatchersType = {
168
175
* Plugin: jest-enzyme
169
176
*/
170
177
type EnzymeMatchersType = {
178
+ // 5.x
179
+ toBeEmpty ( ) : void ,
180
+ toBePresent ( ) : void ,
181
+ // 6.x
171
182
toBeChecked ( ) : void ,
172
183
toBeDisabled ( ) : void ,
173
- toBeEmpty ( ) : void ,
174
184
toBeEmptyRender ( ) : void ,
175
- toBePresent ( ) : void ,
185
+ toContainMatchingElement ( selector : string ) : void ;
186
+ toContainMatchingElements ( n : number , selector : string ) : void ;
187
+ toContainExactlyOneMatchingElement ( selector : string ) : void ;
176
188
toContainReact ( element : React$Element < any > ) : void ,
177
189
toExist ( ) : void ,
178
190
toHaveClassName ( className : string ) : void ,
@@ -183,17 +195,32 @@ type EnzymeMatchersType = {
183
195
toHaveStyle : ( ( styleKey : string , styleValue ? : any ) => void ) & ( ( style : Object ) => void ) ,
184
196
toHaveTagName ( tagName : string ) : void ,
185
197
toHaveText ( text : string ) : void ,
186
- toIncludeText ( text : string ) : void ,
187
198
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 ,
190
207
} ;
191
208
192
209
// DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers
193
210
type 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 ,
194
223
toBeInTheDOM ( ) : void ,
195
- toHaveTextContent ( content : string ) : void ,
196
- toHaveAttribute ( name : string , expectedValue ? : string ) : void
197
224
} ;
198
225
199
226
// Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers
@@ -689,11 +716,14 @@ interface JestExpectType {
689
716
/**
690
717
* This ensures that an Object matches the most recent snapshot.
691
718
*/
692
- toMatchSnapshot ( propertyMatchers ?: { [ key : string ] : JestAsymmetricEqualityType } , name ?: string ) : void ,
719
+ toMatchSnapshot ( propertyMatchers ? : any , name ? : string ) : void ,
693
720
/**
694
721
* This ensures that an Object matches the most recent snapshot.
695
722
*/
696
723
toMatchSnapshot ( name : string ) : void ,
724
+
725
+ toMatchInlineSnapshot ( snapshot ? : string ) : void ,
726
+ toMatchInlineSnapshot ( propertyMatchers ? : any , snapshot ? : string ) : void ,
697
727
/**
698
728
* Use .toThrow to test that a function throws when it is called.
699
729
* If you want to test that a specific error gets thrown, you can provide an
@@ -708,7 +738,8 @@ interface JestExpectType {
708
738
* Use .toThrowErrorMatchingSnapshot to test that a function throws a error
709
739
* matching the most recent snapshot when it is called.
710
740
*/
711
- toThrowErrorMatchingSnapshot ( ) : void
741
+ toThrowErrorMatchingSnapshot ( ) : void ,
742
+ toThrowErrorMatchingInlineSnapshot ( snapshot ? : string ) : void ,
712
743
}
713
744
714
745
type JestObjectType = {
@@ -910,7 +941,20 @@ declare var describe: {
910
941
/**
911
942
* Skip running this describe block
912
943
*/
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 ,
914
958
} ;
915
959
916
960
/** An individual test unit */
@@ -927,17 +971,7 @@ declare var it: {
927
971
fn ?: ( done : ( ) => void ) => ?Promise < mixed > ,
928
972
timeout ?: number
929
973
) : 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
+
941
975
/**
942
976
* Only run this test
943
977
*
@@ -951,12 +985,14 @@ declare var it: {
951
985
timeout ?: number
952
986
) : {
953
987
each (
954
- table : Array < Array < mixed >>
988
+ ... table : Array < Array < mixed > | mixed > | [ Array < string > , string ]
955
989
) : (
956
990
name : JestTestName ,
957
- fn ?: ( ...args : Array < any > ) => ?Promise < mixed >
991
+ fn ?: ( ...args : Array < any > ) => ?Promise < mixed > ,
992
+ timeout ?: number
958
993
) => void ,
959
994
} ,
995
+
960
996
/**
961
997
* Skip running this test
962
998
*
@@ -969,6 +1005,7 @@ declare var it: {
969
1005
fn ?: ( done : ( ) => void ) => ?Promise < mixed > ,
970
1006
timeout ? : number
971
1007
) : void ,
1008
+
972
1009
/**
973
1010
* Run the test concurrently
974
1011
*
@@ -980,8 +1017,22 @@ declare var it: {
980
1017
name : JestTestName ,
981
1018
fn ?: ( done : ( ) => void ) => ?Promise < mixed > ,
982
1019
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 ,
984
1034
} ;
1035
+
985
1036
declare function fit (
986
1037
name : JestTestName ,
987
1038
fn : ( done : ( ) = > void ) => ?Promise < mixed > ,
0 commit comments