1
- // flow-typed signature: e60c7806ec0ddaf4588f438843ef37bd
2
- // flow-typed version: 7afca48d86/jest_v26 .x.x/flow_>=v0.104 .x
1
+ // flow-typed signature: 5ddcf688200e3506308fdcfa78ca48d9
2
+ // flow-typed version: 644a595e77/jest_v27 .x.x/flow_>=v0.134 .x
3
3
4
4
type JestMockFn < TArguments : $ReadOnlyArray < * > , TReturn > = {
5
5
( ...args : TArguments ) : TReturn ,
@@ -54,13 +54,17 @@ type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
54
54
* that come from itself -- the only difference is that the implementation
55
55
* will also be executed when the mock is called.
56
56
*/
57
- mockImplementation ( fn : ( ...args : TArguments ) = > TReturn ) : JestMockFn < TArguments , TReturn > ,
57
+ mockImplementation (
58
+ fn : ( ...args : TArguments ) = > TReturn
59
+ ) : JestMockFn < TArguments , TReturn > ,
58
60
/**
59
61
* Accepts a function that will be used as an implementation of the mock for
60
62
* one call to the mocked function. Can be chained so that multiple function
61
63
* calls produce different results.
62
64
*/
63
- mockImplementationOnce ( fn : ( ...args : TArguments ) = > TReturn ) : JestMockFn < TArguments , TReturn > ,
65
+ mockImplementationOnce (
66
+ fn : ( ...args : TArguments ) = > TReturn
67
+ ) : JestMockFn < TArguments , TReturn > ,
64
68
/**
65
69
* Accepts a string to use in test result output in place of "jest.fn()" to
66
70
* indicate which mock function is being referenced.
@@ -85,7 +89,9 @@ type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
85
89
/**
86
90
* Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value))
87
91
*/
88
- mockResolvedValueOnce ( value : TReturn ) : JestMockFn < TArguments , Promise < TReturn >> ,
92
+ mockResolvedValueOnce (
93
+ value : TReturn
94
+ ) : JestMockFn < TArguments , Promise < TReturn >> ,
89
95
/**
90
96
* Sugar for jest.fn().mockImplementation(() => Promise.reject(value))
91
97
*/
@@ -176,7 +182,7 @@ type JestStyledComponentsMatchersType = {
176
182
toHaveStyleRule (
177
183
property : string ,
178
184
value : JestStyledComponentsMatcherValue ,
179
- options ?: JestStyledComponentsMatcherOptions ,
185
+ options ?: JestStyledComponentsMatcherOptions
180
186
) : void ,
181
187
...
182
188
} ;
@@ -199,17 +205,20 @@ type EnzymeMatchersType = {
199
205
toExist ( ) : void ,
200
206
toHaveClassName ( className : string ) : void ,
201
207
toHaveHTML ( html : string ) : void ,
202
- toHaveProp : ( ( propKey : string , propValue ? : any ) => void ) & ( ( props : { ... } ) => void ) ,
208
+ toHaveProp : ( ( propKey : string , propValue ? : any ) => void ) &
209
+ ( ( props : { ... } ) => void ) ,
203
210
toHaveRef ( refName : string ) : void ,
204
- toHaveState : ( ( stateKey : string , stateValue ? : any ) => void ) & ( ( state : { ... } ) => void ) ,
205
- toHaveStyle : ( ( styleKey : string , styleValue ? : any ) => void ) & ( ( style : { ... } ) => void ) ,
211
+ toHaveState : ( ( stateKey : string , stateValue ? : any ) => void ) &
212
+ ( ( state : { ... } ) => void ) ,
213
+ toHaveStyle : ( ( styleKey : string , styleValue ? : any ) => void ) &
214
+ ( ( style : { ... } ) => void ) ,
206
215
toHaveTagName ( tagName : string ) : void ,
207
216
toHaveText ( text : string ) : void ,
208
217
toHaveValue ( value : any ) : void ,
209
218
toIncludeText ( text : string ) : void ,
210
219
toMatchElement (
211
220
element : React$Element < any > ,
212
- options ?: { | ignoreProps ?: boolean , verbose ?: boolean | } ,
221
+ options ?: { | ignoreProps ?: boolean , verbose ?: boolean | }
213
222
) : void ,
214
223
toMatchSelector ( selector : string ) : void ,
215
224
// 7.x
@@ -241,12 +250,18 @@ type DomTestingLibraryType = {
241
250
toHaveFocus ( ) : void ,
242
251
toHaveFormValues ( expectedValues : { | [ name : string ] : any | } ) : void ,
243
252
toHaveStyle ( css : string | { | [ name : string ] : any | } ) : void ,
244
- toHaveTextContent ( text : string | RegExp , options ?: { | normalizeWhitespace : boolean | } ) : void ,
253
+ toHaveTextContent (
254
+ text : string | RegExp ,
255
+ options ?: { | normalizeWhitespace : boolean | }
256
+ ) : void ,
245
257
toHaveValue ( value ?: string | string [ ] | number ) : void ,
246
258
247
259
// 5.x
248
260
toHaveDisplayValue ( value : string | string [ ] ) : void ,
249
261
toBeChecked ( ) : void ,
262
+ toBeEmptyDOMElement ( ) : void ,
263
+ toBePartiallyChecked ( ) : void ,
264
+ toHaveDescription ( text : string | RegExp ) : void ,
250
265
...
251
266
} ;
252
267
@@ -555,7 +570,7 @@ type SnapshotDiffType = {
555
570
aAnnotation ?: string ,
556
571
bAnnotation ?: string ,
557
572
| } ,
558
- testName ?: string ,
573
+ testName ?: string
559
574
) : void ,
560
575
...
561
576
} ;
@@ -794,6 +809,26 @@ type JestObjectType = {
794
809
* Returns the number of fake timers still left to run.
795
810
*/
796
811
getTimerCount ( ) : number ,
812
+ /**
813
+ * When mocking time, `Date.now()` will also be mocked. If you for
814
+ * some reason need access to the real current time, you can invoke
815
+ * this function.
816
+ *
817
+ * > Note: This function is only available when using modern fake
818
+ * > timers implementation
819
+ */
820
+ getRealSystemTime ( ) : number ,
821
+ /**
822
+ * Set the current system time used by fake timers. Simulates a
823
+ * user changing the system clock while your program is running. It
824
+ * affects the current time but it does not in itself cause e.g.
825
+ * timers to fire; they will fire exactly as they would have done
826
+ * without the call to `jest.setSystemTime()`.
827
+ *
828
+ * > Note: This function is only available when using modern fake
829
+ * > timers implementation
830
+ */
831
+ setSystemTime ( now ?: number | Date ) : void ,
797
832
/**
798
833
* The same as `mock` but not moved to the top of the expectation by
799
834
* babel-jest.
@@ -809,17 +844,21 @@ type JestObjectType = {
809
844
* implementation.
810
845
*/
811
846
fn < TArguments : $ReadOnlyArray < * > , TReturn > (
812
- implementation ?: ( ...args : TArguments ) => TReturn ,
847
+ implementation ?: ( ...args : TArguments ) => TReturn
813
848
) : JestMockFn < TArguments , TReturn > ,
814
849
/**
815
850
* Determines if the given function is a mocked function.
816
851
*/
817
852
isMockFunction ( fn : Function ) : boolean ,
853
+ /**
854
+ * Alias of `createMockFromModule`.
855
+ */
856
+ genMockFromModule ( moduleName : string ) : any ,
818
857
/**
819
858
* Given the name of a module, use the automatic mocking system to generate a
820
859
* mocked version of the module for you.
821
860
*/
822
- genMockFromModule ( moduleName : string ) : any ,
861
+ createMockFromModule ( moduleName : string ) : any ,
823
862
/**
824
863
* Mocks a module with an auto-mocked version when it is being required.
825
864
*
@@ -829,7 +868,11 @@ type JestObjectType = {
829
868
* The third argument can be used to create virtual mocks -- mocks of modules
830
869
* that don't exist anywhere in the system.
831
870
*/
832
- mock ( moduleName : string , moduleFactory ? : any , options ? : Object ) : JestObjectType ,
871
+ mock (
872
+ moduleName : string ,
873
+ moduleFactory ? : any ,
874
+ options ? : Object
875
+ ) : JestObjectType ,
833
876
/**
834
877
* Returns the actual module instead of a mock, bypassing all checks on
835
878
* whether the module should receive a mock implementation or not.
@@ -870,13 +913,6 @@ type JestObjectType = {
870
913
* or setInterval() and setImmediate()).
871
914
*/
872
915
advanceTimersByTime ( msToRun : number ) : void ,
873
- /**
874
- * Executes only the macro task queue (i.e. all tasks queued by setTimeout()
875
- * or setInterval() and setImmediate()).
876
- *
877
- * Renamed to `advanceTimersByTime`.
878
- */
879
- runTimersToTime ( msToRun : number ) : void ,
880
916
/**
881
917
* Executes only the macro-tasks that are currently pending (i.e., only the
882
918
* tasks that have been queued by setTimeout() or setInterval() up to this
@@ -905,31 +941,15 @@ type JestObjectType = {
905
941
* Instructs Jest to use the real versions of the standard timer functions.
906
942
*/
907
943
useRealTimers ( ) : JestObjectType ,
908
- /**
909
- * When mocking time, `Date.now()` will also be mocked. If you for
910
- * some reason need access to the real current time, you can invoke
911
- * this function.
912
- *
913
- * > Note: This function is only available when using modern fake
914
- * > timers implementation
915
- */
916
- getRealSystemTime ( ) : number ,
917
- /**
918
- * Set the current system time used by fake timers. Simulates a
919
- * user changing the system clock while your program is running. It
920
- * affects the current time but it does not in itself cause e.g.
921
- * timers to fire; they will fire exactly as they would have done
922
- * without the call to `jest.setSystemTime()`.
923
- *
924
- * > Note: This function is only available when using modern fake
925
- * > timers implementation
926
- */
927
- setSystemTime ( now ? : number | Date ) : void ,
928
944
/**
929
945
* Creates a mock function similar to jest.fn but also tracks calls to
930
946
* object[methodName].
931
947
*/
932
- spyOn ( object : Object , methodName : string , accessType ? : 'get' | 'set' ) : JestMockFn < any , any > ,
948
+ spyOn (
949
+ object : Object ,
950
+ methodName : string ,
951
+ accessType ? : 'get' | 'set'
952
+ ) : JestMockFn < any , any > ,
933
953
/**
934
954
* Set the default timeout interval for tests and before/after hooks in milliseconds.
935
955
* Note: The default timeout interval is 5 seconds if this method is not called.
@@ -946,13 +966,25 @@ type JestDoneFn = {|
946
966
| } ;
947
967
948
968
/** Runs this function after every test inside this context */
949
- declare function afterEach ( fn : ( done : JestDoneFn ) = > ?Promise < mixed > , timeout ?: number ) : void ;
969
+ declare function afterEach (
970
+ fn : ( done : JestDoneFn ) = > ?Promise < mixed > ,
971
+ timeout ?: number
972
+ ) : void ;
950
973
/** Runs this function before every test inside this context */
951
- declare function beforeEach ( fn : ( done : JestDoneFn ) = > ?Promise < mixed > , timeout ?: number ) : void ;
974
+ declare function beforeEach (
975
+ fn : ( done : JestDoneFn ) = > ?Promise < mixed > ,
976
+ timeout ?: number
977
+ ) : void ;
952
978
/** Runs this function after all tests have finished inside this context */
953
- declare function afterAll ( fn : ( done : JestDoneFn ) = > ?Promise < mixed > , timeout ?: number ) : void ;
979
+ declare function afterAll (
980
+ fn : ( done : JestDoneFn ) = > ?Promise < mixed > ,
981
+ timeout ?: number
982
+ ) : void ;
954
983
/** Runs this function before any tests have started inside this context */
955
- declare function beforeAll ( fn : ( done : JestDoneFn ) = > ?Promise < mixed > , timeout ?: number ) : void ;
984
+ declare function beforeAll (
985
+ fn : ( done : JestDoneFn ) = > ?Promise < mixed > ,
986
+ timeout ?: number
987
+ ) : void ;
956
988
957
989
/** A context for grouping tests together */
958
990
declare var describe : {
@@ -975,7 +1007,11 @@ declare var describe: {
975
1007
*/
976
1008
each (
977
1009
...table : Array < Array < mixed > | mixed > | [ Array < string > , string ]
978
- ) : ( name : JestTestName , fn ?: ( ...args : Array < any > ) => ?Promise < mixed > , timeout ?: number ) => void ,
1010
+ ) : (
1011
+ name : JestTestName ,
1012
+ fn ?: ( ...args : Array < any > ) => ?Promise < mixed > ,
1013
+ timeout ?: number
1014
+ ) => void ,
979
1015
...
980
1016
} ;
981
1017
@@ -988,7 +1024,11 @@ declare var it: {
988
1024
* @param {Function } Test
989
1025
* @param {number } Timeout for the test, in milliseconds.
990
1026
*/
991
- ( name : JestTestName , fn ?: ( done : JestDoneFn ) => ?Promise < mixed > , timeout ?: number ) : void ,
1027
+ (
1028
+ name : JestTestName ,
1029
+ fn ?: ( done : JestDoneFn ) => ?Promise < mixed > ,
1030
+ timeout ?: number
1031
+ ) : void ,
992
1032
/**
993
1033
* Only run this test
994
1034
*
@@ -997,13 +1037,17 @@ declare var it: {
997
1037
* @param {number } Timeout for the test, in milliseconds.
998
1038
*/
999
1039
only : { |
1000
- ( name : JestTestName , fn ?: ( done : JestDoneFn ) => ?Promise < mixed > , timeout ?: number ) : void ,
1040
+ (
1041
+ name : JestTestName ,
1042
+ fn ?: ( done : JestDoneFn ) => ?Promise < mixed > ,
1043
+ timeout ?: number
1044
+ ) : void ,
1001
1045
each (
1002
1046
...table : Array < Array < mixed > | mixed > | [ Array < string > , string ]
1003
1047
) : (
1004
1048
name : JestTestName ,
1005
1049
fn ?: ( ...args : Array < any > ) => ?Promise < mixed > ,
1006
- timeout ?: number ,
1050
+ timeout ?: number
1007
1051
) => void ,
1008
1052
| } ,
1009
1053
/**
@@ -1013,7 +1057,20 @@ declare var it: {
1013
1057
* @param {Function } Test
1014
1058
* @param {number } Timeout for the test, in milliseconds.
1015
1059
*/
1016
- skip ( name : JestTestName , fn ?: ( done : JestDoneFn ) => ?Promise < mixed > , timeout ?: number ) : void ,
1060
+ skip : { |
1061
+ (
1062
+ name : JestTestName ,
1063
+ fn ?: ( done : JestDoneFn ) => ?Promise < mixed > ,
1064
+ timeout ?: number
1065
+ ) : void ,
1066
+ each (
1067
+ ...table : Array < Array < mixed > | mixed > | [ Array < string > , string ]
1068
+ ) : (
1069
+ name : JestTestName ,
1070
+ fn ?: ( ...args : Array < any > ) => ?Promise < mixed > ,
1071
+ timeout ?: number
1072
+ ) = > void ,
1073
+ | } ,
1017
1074
/**
1018
1075
* Highlight planned tests in the summary output
1019
1076
*
@@ -1030,7 +1087,7 @@ declare var it: {
1030
1087
concurrent (
1031
1088
name : JestTestName ,
1032
1089
fn ?: ( done : JestDoneFn ) => ?Promise < mixed > ,
1033
- timeout ?: number ,
1090
+ timeout ?: number
1034
1091
) : void ,
1035
1092
/**
1036
1093
* each runs this test against array of argument arrays per each run
@@ -1039,14 +1096,18 @@ declare var it: {
1039
1096
*/
1040
1097
each (
1041
1098
...table : Array < Array < mixed > | mixed > | [ Array < string > , string ]
1042
- ) : ( name : JestTestName , fn ?: ( ...args : Array < any > ) => ?Promise < mixed > , timeout ?: number ) = > void ,
1099
+ ) : (
1100
+ name : JestTestName ,
1101
+ fn ?: ( ...args : Array < any > ) => ?Promise < mixed > ,
1102
+ timeout ?: number
1103
+ ) => void ,
1043
1104
...
1044
1105
} ;
1045
1106
1046
1107
declare function fit (
1047
1108
name : JestTestName ,
1048
1109
fn : ( done : JestDoneFn ) => ?Promise < mixed > ,
1049
- timeout ?: number ,
1110
+ timeout ?: number
1050
1111
) : void ;
1051
1112
/** An individual test unit */
1052
1113
declare var test : typeof it ;
@@ -1088,9 +1149,9 @@ type JestPrettyFormatColors = {
1088
1149
...
1089
1150
} ;
1090
1151
1091
- type JestPrettyFormatIndent = string => string ;
1152
+ type JestPrettyFormatIndent = ( string ) => string ;
1092
1153
type JestPrettyFormatRefs = Array < any > ;
1093
- type JestPrettyFormatPrint = any => string ;
1154
+ type JestPrettyFormatPrint = ( any ) => string ;
1094
1155
type JestPrettyFormatStringOrNull = string | null ;
1095
1156
1096
1157
type JestPrettyFormatOptions = { |
@@ -1119,9 +1180,9 @@ type JestPrettyFormatPlugin = {
1119
1180
serialize : JestPrettyFormatPrint ,
1120
1181
indent : JestPrettyFormatIndent ,
1121
1182
opts : JestPrettyFormatOptions ,
1122
- colors : JestPrettyFormatColors ,
1183
+ colors : JestPrettyFormatColors
1123
1184
) => string ,
1124
- test : any => boolean ,
1185
+ test : ( any ) => boolean ,
1125
1186
...
1126
1187
} ;
1127
1188
@@ -1131,7 +1192,7 @@ type JestPrettyFormatPlugins = Array<JestPrettyFormatPlugin>;
1131
1192
declare var expect : {
1132
1193
/** The object that you want to make assertions against */
1133
1194
(
1134
- value : any ,
1195
+ value : any
1135
1196
) : JestExpectType &
1136
1197
JestPromiseType &
1137
1198
EnzymeMatchersType &
@@ -1183,7 +1244,7 @@ declare var jasmine: {
1183
1244
createSpy ( name : string ) : JestSpyType ,
1184
1245
createSpyObj (
1185
1246
baseName : string ,
1186
- methodNames : Array < string > ,
1247
+ methodNames : Array < string >
1187
1248
) : { | [ methodName : string ] : JestSpyType | } ,
1188
1249
objectContaining ( value : Object ) : Object ,
1189
1250
stringMatching ( value : string ) : string ,
0 commit comments