Skip to content

Commit aef0f3f

Browse files
committed
2 parents 0d48c55 + 86aff01 commit aef0f3f

26 files changed

+1011
-1107
lines changed

.flowconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ flow-typed/expo-screen-orientation_vx.x.x.js
5959

6060
; Explicitly name these so that Flow sees them instead of their
6161
; counterparts in node_modules/react-native:
62-
flow-typed/jest_v26.x.x.js
62+
flow-typed/jest_v27.x.x.js
6363

6464
[strict]
6565
; These apply only to files where `@flow strict` is enabled.

flow-typed/jest_v26.x.x.js renamed to flow-typed/jest_v27.x.x.js

Lines changed: 122 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
33

44
type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
55
(...args: TArguments): TReturn,
@@ -54,13 +54,17 @@ type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
5454
* that come from itself -- the only difference is that the implementation
5555
* will also be executed when the mock is called.
5656
*/
57-
mockImplementation(fn: (...args: TArguments) => TReturn): JestMockFn<TArguments, TReturn>,
57+
mockImplementation(
58+
fn: (...args: TArguments) => TReturn
59+
): JestMockFn<TArguments, TReturn>,
5860
/**
5961
* Accepts a function that will be used as an implementation of the mock for
6062
* one call to the mocked function. Can be chained so that multiple function
6163
* calls produce different results.
6264
*/
63-
mockImplementationOnce(fn: (...args: TArguments) => TReturn): JestMockFn<TArguments, TReturn>,
65+
mockImplementationOnce(
66+
fn: (...args: TArguments) => TReturn
67+
): JestMockFn<TArguments, TReturn>,
6468
/**
6569
* Accepts a string to use in test result output in place of "jest.fn()" to
6670
* indicate which mock function is being referenced.
@@ -85,7 +89,9 @@ type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
8589
/**
8690
* Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value))
8791
*/
88-
mockResolvedValueOnce(value: TReturn): JestMockFn<TArguments, Promise<TReturn>>,
92+
mockResolvedValueOnce(
93+
value: TReturn
94+
): JestMockFn<TArguments, Promise<TReturn>>,
8995
/**
9096
* Sugar for jest.fn().mockImplementation(() => Promise.reject(value))
9197
*/
@@ -176,7 +182,7 @@ type JestStyledComponentsMatchersType = {
176182
toHaveStyleRule(
177183
property: string,
178184
value: JestStyledComponentsMatcherValue,
179-
options?: JestStyledComponentsMatcherOptions,
185+
options?: JestStyledComponentsMatcherOptions
180186
): void,
181187
...
182188
};
@@ -199,17 +205,20 @@ type EnzymeMatchersType = {
199205
toExist(): void,
200206
toHaveClassName(className: string): void,
201207
toHaveHTML(html: string): void,
202-
toHaveProp: ((propKey: string, propValue?: any) => void) & ((props: { ... }) => void),
208+
toHaveProp: ((propKey: string, propValue?: any) => void) &
209+
((props: { ... }) => void),
203210
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),
206215
toHaveTagName(tagName: string): void,
207216
toHaveText(text: string): void,
208217
toHaveValue(value: any): void,
209218
toIncludeText(text: string): void,
210219
toMatchElement(
211220
element: React$Element<any>,
212-
options?: {| ignoreProps?: boolean, verbose?: boolean |},
221+
options?: {| ignoreProps?: boolean, verbose?: boolean |}
213222
): void,
214223
toMatchSelector(selector: string): void,
215224
// 7.x
@@ -241,12 +250,18 @@ type DomTestingLibraryType = {
241250
toHaveFocus(): void,
242251
toHaveFormValues(expectedValues: {| [name: string]: any |}): void,
243252
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,
245257
toHaveValue(value?: string | string[] | number): void,
246258

247259
// 5.x
248260
toHaveDisplayValue(value: string | string[]): void,
249261
toBeChecked(): void,
262+
toBeEmptyDOMElement(): void,
263+
toBePartiallyChecked(): void,
264+
toHaveDescription(text: string | RegExp): void,
250265
...
251266
};
252267

@@ -555,7 +570,7 @@ type SnapshotDiffType = {
555570
aAnnotation?: string,
556571
bAnnotation?: string,
557572
|},
558-
testName?: string,
573+
testName?: string
559574
): void,
560575
...
561576
};
@@ -794,6 +809,26 @@ type JestObjectType = {
794809
* Returns the number of fake timers still left to run.
795810
*/
796811
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,
797832
/**
798833
* The same as `mock` but not moved to the top of the expectation by
799834
* babel-jest.
@@ -809,17 +844,21 @@ type JestObjectType = {
809844
* implementation.
810845
*/
811846
fn<TArguments: $ReadOnlyArray<*>, TReturn>(
812-
implementation?: (...args: TArguments) => TReturn,
847+
implementation?: (...args: TArguments) => TReturn
813848
): JestMockFn<TArguments, TReturn>,
814849
/**
815850
* Determines if the given function is a mocked function.
816851
*/
817852
isMockFunction(fn: Function): boolean,
853+
/**
854+
* Alias of `createMockFromModule`.
855+
*/
856+
genMockFromModule(moduleName: string): any,
818857
/**
819858
* Given the name of a module, use the automatic mocking system to generate a
820859
* mocked version of the module for you.
821860
*/
822-
genMockFromModule(moduleName: string): any,
861+
createMockFromModule(moduleName: string): any,
823862
/**
824863
* Mocks a module with an auto-mocked version when it is being required.
825864
*
@@ -829,7 +868,11 @@ type JestObjectType = {
829868
* The third argument can be used to create virtual mocks -- mocks of modules
830869
* that don't exist anywhere in the system.
831870
*/
832-
mock(moduleName: string, moduleFactory?: any, options?: Object): JestObjectType,
871+
mock(
872+
moduleName: string,
873+
moduleFactory?: any,
874+
options?: Object
875+
): JestObjectType,
833876
/**
834877
* Returns the actual module instead of a mock, bypassing all checks on
835878
* whether the module should receive a mock implementation or not.
@@ -870,13 +913,6 @@ type JestObjectType = {
870913
* or setInterval() and setImmediate()).
871914
*/
872915
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,
880916
/**
881917
* Executes only the macro-tasks that are currently pending (i.e., only the
882918
* tasks that have been queued by setTimeout() or setInterval() up to this
@@ -905,31 +941,15 @@ type JestObjectType = {
905941
* Instructs Jest to use the real versions of the standard timer functions.
906942
*/
907943
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,
928944
/**
929945
* Creates a mock function similar to jest.fn but also tracks calls to
930946
* object[methodName].
931947
*/
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>,
933953
/**
934954
* Set the default timeout interval for tests and before/after hooks in milliseconds.
935955
* Note: The default timeout interval is 5 seconds if this method is not called.
@@ -946,13 +966,25 @@ type JestDoneFn = {|
946966
|};
947967

948968
/** 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;
950973
/** 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;
952978
/** 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;
954983
/** 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;
956988

957989
/** A context for grouping tests together */
958990
declare var describe: {
@@ -975,7 +1007,11 @@ declare var describe: {
9751007
*/
9761008
each(
9771009
...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,
9791015
...
9801016
};
9811017

@@ -988,7 +1024,11 @@ declare var it: {
9881024
* @param {Function} Test
9891025
* @param {number} Timeout for the test, in milliseconds.
9901026
*/
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,
9921032
/**
9931033
* Only run this test
9941034
*
@@ -997,13 +1037,17 @@ declare var it: {
9971037
* @param {number} Timeout for the test, in milliseconds.
9981038
*/
9991039
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,
10011045
each(
10021046
...table: Array<Array<mixed> | mixed> | [Array<string>, string]
10031047
): (
10041048
name: JestTestName,
10051049
fn?: (...args: Array<any>) => ?Promise<mixed>,
1006-
timeout?: number,
1050+
timeout?: number
10071051
) => void,
10081052
|},
10091053
/**
@@ -1013,7 +1057,20 @@ declare var it: {
10131057
* @param {Function} Test
10141058
* @param {number} Timeout for the test, in milliseconds.
10151059
*/
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+
|},
10171074
/**
10181075
* Highlight planned tests in the summary output
10191076
*
@@ -1030,7 +1087,7 @@ declare var it: {
10301087
concurrent(
10311088
name: JestTestName,
10321089
fn?: (done: JestDoneFn) => ?Promise<mixed>,
1033-
timeout?: number,
1090+
timeout?: number
10341091
): void,
10351092
/**
10361093
* each runs this test against array of argument arrays per each run
@@ -1039,14 +1096,18 @@ declare var it: {
10391096
*/
10401097
each(
10411098
...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,
10431104
...
10441105
};
10451106

10461107
declare function fit(
10471108
name: JestTestName,
10481109
fn: (done: JestDoneFn) => ?Promise<mixed>,
1049-
timeout?: number,
1110+
timeout?: number
10501111
): void;
10511112
/** An individual test unit */
10521113
declare var test: typeof it;
@@ -1088,9 +1149,9 @@ type JestPrettyFormatColors = {
10881149
...
10891150
};
10901151

1091-
type JestPrettyFormatIndent = string => string;
1152+
type JestPrettyFormatIndent = (string) => string;
10921153
type JestPrettyFormatRefs = Array<any>;
1093-
type JestPrettyFormatPrint = any => string;
1154+
type JestPrettyFormatPrint = (any) => string;
10941155
type JestPrettyFormatStringOrNull = string | null;
10951156

10961157
type JestPrettyFormatOptions = {|
@@ -1119,9 +1180,9 @@ type JestPrettyFormatPlugin = {
11191180
serialize: JestPrettyFormatPrint,
11201181
indent: JestPrettyFormatIndent,
11211182
opts: JestPrettyFormatOptions,
1122-
colors: JestPrettyFormatColors,
1183+
colors: JestPrettyFormatColors
11231184
) => string,
1124-
test: any => boolean,
1185+
test: (any) => boolean,
11251186
...
11261187
};
11271188

@@ -1131,7 +1192,7 @@ type JestPrettyFormatPlugins = Array<JestPrettyFormatPlugin>;
11311192
declare var expect: {
11321193
/** The object that you want to make assertions against */
11331194
(
1134-
value: any,
1195+
value: any
11351196
): JestExpectType &
11361197
JestPromiseType &
11371198
EnzymeMatchersType &
@@ -1183,7 +1244,7 @@ declare var jasmine: {
11831244
createSpy(name: string): JestSpyType,
11841245
createSpyObj(
11851246
baseName: string,
1186-
methodNames: Array<string>,
1247+
methodNames: Array<string>
11871248
): {| [methodName: string]: JestSpyType |},
11881249
objectContaining(value: Object): Object,
11891250
stringMatching(value: string): string,

0 commit comments

Comments
 (0)