@office-iss/react-native-win32 0.79.0-preview.2 → 0.80.0-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.flowconfig +10 -3
- package/CHANGELOG.json +120 -12
- package/CHANGELOG.md +50 -7
- package/IntegrationTests/ImageCachePolicyTest.js +1 -1
- package/IntegrationTests/LayoutEventsTest.js +1 -4
- package/Libraries/Alert/Alert.d.ts +4 -1
- package/Libraries/Alert/Alert.js +3 -0
- package/Libraries/Alert/RCTAlertManager.js +17 -0
- package/Libraries/Animated/Animated.js.flow +1 -3
- package/Libraries/Animated/AnimatedEvent.js +4 -3
- package/Libraries/Animated/AnimatedExports.js +2 -2
- package/Libraries/Animated/AnimatedExports.js.flow +140 -0
- package/Libraries/Animated/AnimatedImplementation.js +2 -123
- package/Libraries/Animated/Easing.js +13 -15
- package/Libraries/Animated/animations/Animation.js +8 -4
- package/Libraries/Animated/components/AnimatedFlatList.js +7 -6
- package/Libraries/Animated/components/AnimatedScrollView.js +48 -42
- package/Libraries/Animated/components/AnimatedSectionList.js +11 -7
- package/Libraries/Animated/createAnimatedComponent.js +105 -57
- package/Libraries/Animated/nodes/AnimatedNode.js +4 -3
- package/Libraries/Animated/nodes/AnimatedProps.js +46 -26
- package/Libraries/Animated/nodes/AnimatedValue.js +16 -7
- package/Libraries/Animated/nodes/AnimatedValueXY.js +3 -1
- package/Libraries/AppState/AppState.js +7 -2
- package/Libraries/BatchedBridge/MessageQueue.js +2 -2
- package/Libraries/BatchedBridge/NativeModules.js +2 -0
- package/Libraries/Blob/BlobManager.js +1 -0
- package/Libraries/Blob/FileReader.js +219 -8
- package/Libraries/Blob/URL.js +37 -12
- package/Libraries/Blob/URLSearchParams.js +106 -31
- package/Libraries/Blob/URLSearchParams.js.flow +12 -7
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +1 -1
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +1 -1
- package/Libraries/Components/AccessibilityInfo/legacySendAccessibilityEvent.js +17 -0
- package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +1 -0
- package/Libraries/Components/Button.js +1 -1
- package/Libraries/Components/Button.win32.js +1 -1
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -3
- package/Libraries/{NewAppScreen/components/Colors.js → Components/DrawerAndroid/DrawerLayoutAndroid.ios.js} +6 -10
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js +6 -66
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.js.flow +18 -0
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidFallback.js +71 -0
- package/Libraries/Components/Keyboard/Keyboard.js +5 -3
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +6 -3
- package/Libraries/Components/Pressable/Pressable.js +20 -4
- package/Libraries/Components/Pressable/Pressable.win32.js +20 -4
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +25 -3
- package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidTypes.js +29 -20
- package/Libraries/Components/RefreshControl/RefreshControl.js +1 -1
- package/Libraries/Components/ScrollView/ScrollView.d.ts +3 -3
- package/Libraries/Components/ScrollView/ScrollView.js +132 -122
- package/Libraries/Components/StaticRenderer.js +1 -1
- package/Libraries/Components/Switch/Switch.d.ts +3 -0
- package/Libraries/Components/Switch/Switch.js +8 -4
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +2 -1
- package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +2 -4
- package/Libraries/Components/TextInput/Tests/TextInputTest.d.ts +2 -1
- package/Libraries/Components/TextInput/Tests/TextInputTest.js.map +1 -1
- package/Libraries/Components/TextInput/TextInput.d.ts +70 -33
- package/Libraries/Components/TextInput/TextInput.flow.js +100 -51
- package/Libraries/Components/TextInput/TextInput.flow.win32.js +1208 -0
- package/Libraries/Components/TextInput/TextInput.js +88 -1027
- package/Libraries/Components/TextInput/TextInput.win32.js +89 -1059
- package/Libraries/Components/TextInput/TextInputState.js +1 -1
- package/Libraries/Components/TextInput/TextInputState.win32.js +1 -1
- package/Libraries/{Modal/ModalInjection.js → Components/ToastAndroid/ToastAndroid.ios.js} +3 -5
- package/Libraries/Components/ToastAndroid/ToastAndroid.js +4 -32
- package/Libraries/Components/ToastAndroid/ToastAndroid.js.flow +109 -0
- package/Libraries/Components/ToastAndroid/ToastAndroid.win32.js +4 -32
- package/Libraries/Components/ToastAndroid/ToastAndroidFallback.js +45 -0
- package/Libraries/Components/Touchable/Tests/TouchableWin32Test.d.ts +2 -1
- package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
- package/Libraries/Components/Touchable/Touchable.js +5 -5
- package/Libraries/Components/Touchable/Touchable.win32.js +5 -5
- package/Libraries/Components/Touchable/TouchableBounce.js +14 -7
- package/Libraries/Components/Touchable/TouchableHighlight.js +10 -7
- package/Libraries/Components/Touchable/TouchableNativeFeedback.js +6 -6
- package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +6 -6
- package/Libraries/Components/Touchable/TouchableOpacity.js +13 -6
- package/Libraries/Components/View/View.js +18 -21
- package/Libraries/Components/View/View.win32.js +21 -24
- package/Libraries/Components/View/ViewAccessibility.js +25 -1
- package/Libraries/Components/View/ViewAccessibility.win32.js +9 -1
- package/Libraries/Components/View/ViewPropTypes.js +49 -3
- package/Libraries/Components/View/ViewPropTypes.win32.js +49 -3
- package/Libraries/Core/ReactNativeVersion.js +2 -2
- package/Libraries/Core/setUpReactDevTools.js +5 -5
- package/Libraries/Debugging/DebuggingOverlayRegistry.js +3 -3
- package/Libraries/EventEmitter/NativeEventEmitter.js +9 -4
- package/Libraries/Image/AssetSourceResolver.js +17 -4
- package/Libraries/Image/Image.d.ts +26 -10
- package/Libraries/Image/Image.js +17 -0
- package/Libraries/Image/Image.js.flow +5 -5
- package/Libraries/Image/ImageBackground.js +2 -0
- package/Libraries/Image/ImageInjection.js +1 -1
- package/Libraries/Image/ImageProps.js +22 -17
- package/Libraries/Image/ImageSource.js +3 -1
- package/Libraries/Image/ImageSourceUtils.js +4 -2
- package/Libraries/Image/ImageTypes.flow.js +1 -1
- package/Libraries/Image/Tests/ImageWin32Test.d.ts +2 -1
- package/Libraries/Image/Tests/ImageWin32Test.js.map +1 -1
- package/Libraries/Interaction/InteractionManager.d.ts +13 -0
- package/Libraries/Interaction/InteractionManager.js +1 -1
- package/Libraries/Interaction/PanResponder.js +3 -3
- package/Libraries/Interaction/TaskQueue.js +1 -0
- package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -2
- package/Libraries/Linking/Linking.js +1 -1
- package/Libraries/Lists/FlatList.d.ts +2 -2
- package/Libraries/Lists/FlatList.js +8 -11
- package/Libraries/Lists/SectionList.js +39 -42
- package/Libraries/Lists/SectionListModern.js +25 -34
- package/Libraries/Lists/VirtualizedList.js +1 -0
- package/Libraries/Lists/VirtualizedSectionList.js +1 -0
- package/Libraries/LogBox/Data/LogBoxData.js +1 -1
- package/Libraries/LogBox/LogBoxNotificationContainer.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.win32.js +140 -0
- package/Libraries/Modal/Modal.js +33 -7
- package/Libraries/NativeComponent/BaseViewConfig.android.js +2 -0
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +2 -0
- package/Libraries/NativeComponent/BaseViewConfig.js +17 -0
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +1 -0
- package/Libraries/NativeComponent/PlatformBaseViewConfig.js +2 -2
- package/Libraries/NativeModules/specs/NativeDevMenu.js +2 -2
- package/Libraries/Network/RCTNetworking.android.js +1 -1
- package/Libraries/Network/RCTNetworking.ios.js +1 -1
- package/Libraries/Network/RCTNetworking.js +17 -0
- package/Libraries/Network/RCTNetworking.js.flow +1 -1
- package/Libraries/Network/RCTNetworking.win32.js +1 -1
- package/Libraries/Network/XMLHttpRequest.js +781 -10
- package/Libraries/Performance/Systrace.js +7 -7
- package/Libraries/Pressability/Pressability.js +1 -1
- package/Libraries/Pressability/Pressability.win32.js +1 -1
- package/Libraries/ReactNative/AppContainer-dev.js +5 -4
- package/Libraries/ReactNative/AppRegistry.flow.js +49 -0
- package/Libraries/ReactNative/AppRegistry.js +2 -322
- package/Libraries/ReactNative/AppRegistry.js.flow +23 -0
- package/Libraries/ReactNative/AppRegistryImpl.js +316 -0
- package/Libraries/ReactNative/FabricUIManager.js +10 -0
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -4
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +1 -4
- package/Libraries/ReactNative/RendererImplementation.js +10 -5
- package/Libraries/ReactNative/getNativeComponentAttributes.js +1 -0
- package/Libraries/ReactNative/renderApplication.js +9 -0
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +3 -3
- package/Libraries/ReactPrivate/ReactNativePrivateInterface.js.flow +51 -0
- package/Libraries/Renderer/implementations/ReactFabric-dev.js +4840 -4748
- package/Libraries/Renderer/implementations/ReactFabric-prod.js +4947 -4829
- package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3998 -3888
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +5005 -4948
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +2744 -2652
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +5020 -4933
- package/Libraries/Renderer/shims/ReactNativeTypes.js +3 -3
- package/Libraries/Settings/Settings.ios.js +1 -0
- package/Libraries/Settings/Settings.js +13 -19
- package/Libraries/Settings/Settings.win32.js +19 -20
- package/Libraries/Settings/SettingsFallback.js +33 -0
- package/Libraries/StyleSheet/PlatformColorValueTypes.js +15 -0
- package/Libraries/StyleSheet/PlatformColorValueTypesIOS.js +6 -0
- package/Libraries/StyleSheet/Rect.js +1 -0
- package/Libraries/StyleSheet/StyleSheet.js +31 -200
- package/Libraries/StyleSheet/StyleSheet.js.flow +188 -0
- package/Libraries/StyleSheet/{StyleSheet.win32.js → StyleSheetExports.js} +2 -151
- package/Libraries/StyleSheet/StyleSheetExports.js.flow +112 -0
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -1
- package/Libraries/StyleSheet/StyleSheetTypes.js +130 -52
- package/Libraries/StyleSheet/flattenStyle.js +14 -4
- package/Libraries/StyleSheet/private/_TransformStyle.js +49 -21
- package/Libraries/StyleSheet/processBackgroundImage.js +670 -214
- package/Libraries/Text/Text.d.ts +2 -5
- package/Libraries/Text/Text.js +3 -3
- package/Libraries/Text/Text.win32.js +3 -3
- package/Libraries/Text/TextNativeComponent.js +0 -4
- package/Libraries/Text/TextNativeComponent.win32.js +0 -4
- package/Libraries/Text/TextProps.js +5 -33
- package/Libraries/Text/TextProps.win32.js +5 -30
- package/Libraries/Types/CodegenTypesNamespace.d.ts +45 -0
- package/Libraries/{Blob/__mocks__/BlobModule.js → Types/CodegenTypesNamespace.js} +4 -6
- package/Libraries/Types/CoreEventTypes.d.ts +6 -1
- package/Libraries/Types/CoreEventTypes.js +1 -1
- package/Libraries/Types/CoreEventTypes.win32.js +1 -1
- package/Libraries/Utilities/Appearance.js +2 -0
- package/Libraries/Utilities/BackHandler.js +17 -0
- package/Libraries/Utilities/DeviceInfo.js +2 -0
- package/Libraries/Utilities/Dimensions.js +1 -1
- package/Libraries/Utilities/Dimensions.win32.js +1 -1
- package/Libraries/Utilities/Platform.js +17 -0
- package/Libraries/Utilities/PlatformTypes.js +11 -3
- package/Libraries/Utilities/ReactNativeTestTools.js +2 -2
- package/Libraries/Utilities/codegenNativeCommands.d.ts +18 -0
- package/Libraries/Utilities/codegenNativeComponent.d.ts +26 -0
- package/Libraries/WebSocket/WebSocket.js +313 -8
- package/Libraries/vendor/core/ErrorUtils.js +28 -2
- package/Libraries/vendor/emitter/EventEmitter.js +6 -2
- package/flow/global.js +1 -0
- package/index.js +51 -331
- package/index.win32.js +71 -352
- package/interface.js +0 -4
- package/jest/resolver.js +31 -0
- package/overrides.json +45 -47
- package/package.json +24 -24
- package/src/private/animated/NativeAnimatedHelper.js +21 -8
- package/src/private/animated/NativeAnimatedHelper.win32.js +21 -8
- package/src/private/animated/createAnimatedPropsHook.js +11 -16
- package/src/private/animated/createAnimatedPropsMemoHook.js +1 -2
- package/src/private/components/{SafeAreaView_INTERNAL_DO_NOT_USE.js → safeareaview/SafeAreaView_INTERNAL_DO_NOT_USE.js} +6 -6
- package/src/private/components/{HScrollViewNativeComponents.js → scrollview/HScrollViewNativeComponents.js} +8 -8
- package/src/private/components/scrollview/VScrollViewNativeComponents.js +25 -0
- package/src/private/{devmenu → devsupport/devmenu}/DevMenu.js +1 -1
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/BorderBox.js +3 -3
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/BoxInspector.js +6 -5
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/ElementBox.js +8 -6
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/ElementProperties.js +11 -10
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/Inspector.js +14 -12
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/InspectorOverlay.js +5 -4
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/InspectorPanel.js +9 -8
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/NetworkOverlay.js +10 -9
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/ReactDevToolsOverlay.js +7 -7
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/StyleInspector.js +7 -6
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/XHRInterceptor.js +2 -2
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/getInspectorDataForViewAtPoint.js +4 -4
- package/src/private/{inspector → devsupport/devmenu/elementinspector}/resolveBoxStyle.js +1 -1
- package/src/private/{inspector → devsupport/devmenu/perfmonitor}/PerformanceOverlay.js +6 -5
- package/src/private/{specs_DEPRECATED/modules → devsupport/devmenu/specs}/NativeDevMenu.js +2 -2
- package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.android.js +1 -1
- package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.ios.js +1 -1
- package/src/private/{debugging → devsupport/rndevtools}/ReactDevToolsSettingsManager.win32.js +1 -1
- package/src/private/{debugging → devsupport/rndevtools}/setUpFuseboxReactDevToolsDispatcher.js +1 -1
- package/src/private/{fusebox → devsupport/rndevtools}/specs/NativeReactDevToolsRuntimeSettingsModule.js +2 -2
- package/src/private/{specs_DEPRECATED/modules → devsupport/rndevtools/specs}/NativeReactDevToolsSettingsManager.js +2 -2
- package/src/private/featureflags/ReactNativeFeatureFlags.js +82 -80
- package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +9 -1
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +17 -13
- package/src/private/renderer/errorhandling/ErrorHandlers.js +2 -2
- package/src/private/specs_DEPRECATED/modules/NativeAnimatedModule.js +1 -1
- package/src/private/specs_DEPRECATED/modules/NativeAnimatedTurboModule.js +1 -1
- package/src/private/specs_DEPRECATED/modules/NativeSampleTurboModule.js +3 -0
- package/src/private/styles/composeStyles.js +12 -5
- package/src/private/types/HostComponent.js +1 -1
- package/src/private/types/HostInstance.js +67 -1
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +2 -5
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +5 -18
- package/src/private/webapis/dom/nodes/internals/NodeInternals.js +6 -0
- package/src/private/webapis/performance/Performance.js +1 -3
- package/src/private/webapis/performance/PerformanceEntry.js +6 -1
- package/src/private/webapis/performance/internals/RawPerformanceEntry.js +3 -0
- package/src/private/webapis/performance/specs/NativePerformance.js +10 -1
- package/src/types/globals.d.ts +42 -0
- package/src-win/Libraries/Components/TextInput/Tests/TextInputTest.tsx +7 -7
- package/src-win/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +3 -3
- package/src-win/Libraries/Image/Tests/ImageWin32Test.tsx +1 -1
- package/src-win/Libraries/Text/Text.d.ts +2 -5
- package/types/index.d.ts +6 -3
- package/types/public/ReactNativeTypes.d.ts +2 -2
- package/Libraries/BatchedBridge/__mocks__/MessageQueueTestConfig.js +0 -38
- package/Libraries/BatchedBridge/__mocks__/MessageQueueTestModule.js +0 -22
- package/Libraries/Blob/FileReader_new.js +0 -231
- package/Libraries/Blob/FileReader_old.js +0 -186
- package/Libraries/Blob/__mocks__/FileReaderModule.js +0 -20
- package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +0 -32
- package/Libraries/Core/__mocks__/ErrorUtils.js +0 -33
- package/Libraries/Core/__mocks__/NativeExceptionsManager.js +0 -19
- package/Libraries/EventEmitter/__mocks__/NativeEventEmitter.js +0 -49
- package/Libraries/Events/CustomEvent.js +0 -32
- package/Libraries/Events/EventPolyfill.js +0 -239
- package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +0 -118
- package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +0 -134
- package/Libraries/Network/XMLHttpRequest_new.js +0 -794
- package/Libraries/Network/XMLHttpRequest_old.js +0 -701
- package/Libraries/NewAppScreen/components/DebugInstructions.js +0 -41
- package/Libraries/NewAppScreen/components/Header.js +0 -77
- package/Libraries/NewAppScreen/components/HermesBadge.js +0 -53
- package/Libraries/NewAppScreen/components/LearnMoreLinks.js +0 -148
- package/Libraries/NewAppScreen/components/ReloadInstructions.js +0 -39
- package/Libraries/NewAppScreen/components/logo.png +0 -0
- package/Libraries/NewAppScreen/index.js +0 -25
- package/Libraries/StyleSheet/__flowtests__/StyleSheet-flowtest.js +0 -58
- package/Libraries/Utilities/DeviceInfo.win32.js +0 -19
- package/Libraries/Utilities/__mocks__/BackHandler.js +0 -45
- package/Libraries/Utilities/__mocks__/GlobalPerformanceLogger.js +0 -16
- package/Libraries/Utilities/__mocks__/PixelRatio.js +0 -25
- package/Libraries/WebSocket/WebSocketEvent.js +0 -30
- package/Libraries/WebSocket/WebSocket_new.js +0 -325
- package/Libraries/WebSocket/WebSocket_old.js +0 -297
- package/Libraries/WebSocket/__mocks__/event-target-shim.js +0 -27
- package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +0 -30
- package/Libraries/vendor/emitter/__flowtests__/EventEmitter-flowtest.js +0 -81
- package/flow/jest.js +0 -1287
- package/jest/__tests__/setup-test.js +0 -18
- package/src/private/components/VScrollViewNativeComponents.js +0 -25
- package/src/private/utilities/ensureInstance.js +0 -21
- package/src/private/webapis/performance/specs/__mocks__/NativePerformanceMock.js +0 -267
- package/types/modules/LaunchScreen.d.ts +0 -18
- /package/src/private/{devmenu → devsupport/devmenu}/DevMenu.d.ts +0 -0
- /package/src/private/{debugging → devsupport/rndevtools}/FuseboxSessionObserver.js +0 -0
package/flow/jest.js
DELETED
|
@@ -1,1287 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
* @flow strict-local
|
|
8
|
-
* @format
|
|
9
|
-
* @oncall react_native
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
// Modified from https://raw.githubusercontent.com/flow-typed/flow-typed/master/definitions/npm/jest_v29.x.x/flow_v0.134.x-/jest_v29.x.x.js
|
|
13
|
-
// Modifications are explained inline by comments beginning with `// MODIFIED`.
|
|
14
|
-
|
|
15
|
-
// MODIFIED: Added ESLint suppression comment - no-unused-vars doesn't understand declaration files
|
|
16
|
-
/* eslint-disable no-unused-vars */
|
|
17
|
-
|
|
18
|
-
type JestMockFn<TArguments: $ReadOnlyArray<any>, TReturn> = {
|
|
19
|
-
(...args: TArguments): TReturn,
|
|
20
|
-
/**
|
|
21
|
-
* An object for introspecting mock calls
|
|
22
|
-
*/
|
|
23
|
-
mock: {
|
|
24
|
-
/**
|
|
25
|
-
* An array that represents all calls that have been made into this mock
|
|
26
|
-
* function. Each call is represented by an array of arguments that were
|
|
27
|
-
* passed during the call.
|
|
28
|
-
*/
|
|
29
|
-
calls: Array<TArguments>,
|
|
30
|
-
/**
|
|
31
|
-
* An array containing the call arguments of the last call that was made
|
|
32
|
-
* to this mock function. If the function was not called, it will return
|
|
33
|
-
* undefined.
|
|
34
|
-
*/
|
|
35
|
-
lastCall: TArguments,
|
|
36
|
-
/**
|
|
37
|
-
* An array that contains all the object instances that have been
|
|
38
|
-
* instantiated from this mock function.
|
|
39
|
-
*/
|
|
40
|
-
instances: Array<TReturn>,
|
|
41
|
-
/**
|
|
42
|
-
* An array that contains the contexts for all calls of the mock function.
|
|
43
|
-
*/
|
|
44
|
-
contexts: Array<mixed>,
|
|
45
|
-
/**
|
|
46
|
-
* An array that contains all the object results that have been
|
|
47
|
-
* returned by this mock function call
|
|
48
|
-
*/
|
|
49
|
-
results: Array<{
|
|
50
|
-
isThrow: boolean,
|
|
51
|
-
value: TReturn,
|
|
52
|
-
...
|
|
53
|
-
}>,
|
|
54
|
-
...
|
|
55
|
-
},
|
|
56
|
-
/**
|
|
57
|
-
* Resets all information stored in the mockFn.mock.calls and
|
|
58
|
-
* mockFn.mock.instances arrays. Often this is useful when you want to clean
|
|
59
|
-
* up a mock's usage data between two assertions.
|
|
60
|
-
*/
|
|
61
|
-
mockClear(): void,
|
|
62
|
-
/**
|
|
63
|
-
* Resets all information stored in the mock. This is useful when you want to
|
|
64
|
-
* completely restore a mock back to its initial state.
|
|
65
|
-
*/
|
|
66
|
-
mockReset(): void,
|
|
67
|
-
/**
|
|
68
|
-
* Removes the mock and restores the initial implementation. This is useful
|
|
69
|
-
* when you want to mock functions in certain test cases and restore the
|
|
70
|
-
* original implementation in others. Beware that mockFn.mockRestore only
|
|
71
|
-
* works when mock was created with jest.spyOn. Thus you have to take care of
|
|
72
|
-
* restoration yourself when manually assigning jest.fn().
|
|
73
|
-
*/
|
|
74
|
-
mockRestore(): void,
|
|
75
|
-
/**
|
|
76
|
-
* Accepts a function that should be used as the implementation of the mock.
|
|
77
|
-
* The mock itself will still record all calls that go into and instances
|
|
78
|
-
* that come from itself -- the only difference is that the implementation
|
|
79
|
-
* will also be executed when the mock is called.
|
|
80
|
-
*/
|
|
81
|
-
mockImplementation(
|
|
82
|
-
fn: (...args: TArguments) => TReturn,
|
|
83
|
-
): JestMockFn<TArguments, TReturn>,
|
|
84
|
-
/**
|
|
85
|
-
* Accepts a function that will be used as an implementation of the mock for
|
|
86
|
-
* one call to the mocked function. Can be chained so that multiple function
|
|
87
|
-
* calls produce different results.
|
|
88
|
-
*/
|
|
89
|
-
mockImplementationOnce(
|
|
90
|
-
fn: (...args: TArguments) => TReturn,
|
|
91
|
-
): JestMockFn<TArguments, TReturn>,
|
|
92
|
-
/**
|
|
93
|
-
* Accepts a string to use in test result output in place of "jest.fn()" to
|
|
94
|
-
* indicate which mock function is being referenced.
|
|
95
|
-
*/
|
|
96
|
-
mockName(name: string): JestMockFn<TArguments, TReturn>,
|
|
97
|
-
/**
|
|
98
|
-
* Just a simple sugar function for returning `this`
|
|
99
|
-
*/
|
|
100
|
-
mockReturnThis(): void,
|
|
101
|
-
/**
|
|
102
|
-
* Accepts a value that will be returned whenever the mock function is called.
|
|
103
|
-
*/
|
|
104
|
-
mockReturnValue(value: TReturn): JestMockFn<TArguments, TReturn>,
|
|
105
|
-
/**
|
|
106
|
-
* Sugar for only returning a value once inside your mock
|
|
107
|
-
*/
|
|
108
|
-
mockReturnValueOnce(value: TReturn): JestMockFn<TArguments, TReturn>,
|
|
109
|
-
/**
|
|
110
|
-
* Sugar for jest.fn().mockImplementation(() => Promise.resolve(value))
|
|
111
|
-
*/
|
|
112
|
-
mockResolvedValue(value: TReturn): JestMockFn<TArguments, Promise<TReturn>>,
|
|
113
|
-
/**
|
|
114
|
-
* Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value))
|
|
115
|
-
*/
|
|
116
|
-
mockResolvedValueOnce(
|
|
117
|
-
value: TReturn,
|
|
118
|
-
): JestMockFn<TArguments, Promise<TReturn>>,
|
|
119
|
-
/**
|
|
120
|
-
* Sugar for jest.fn().mockImplementation(() => Promise.reject(value))
|
|
121
|
-
*/
|
|
122
|
-
mockRejectedValue(value: TReturn): JestMockFn<TArguments, Promise<any>>,
|
|
123
|
-
/**
|
|
124
|
-
* Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value))
|
|
125
|
-
*/
|
|
126
|
-
mockRejectedValueOnce(value: TReturn): JestMockFn<TArguments, Promise<any>>,
|
|
127
|
-
...
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
type JestAsymmetricEqualityType = {
|
|
131
|
-
/**
|
|
132
|
-
* A custom Jasmine equality tester
|
|
133
|
-
*/
|
|
134
|
-
asymmetricMatch(value: mixed): boolean,
|
|
135
|
-
...
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
type JestCallsType = {
|
|
139
|
-
allArgs(): mixed,
|
|
140
|
-
all(): mixed,
|
|
141
|
-
any(): boolean,
|
|
142
|
-
count(): number,
|
|
143
|
-
first(): mixed,
|
|
144
|
-
mostRecent(): mixed,
|
|
145
|
-
reset(): void,
|
|
146
|
-
...
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
type JestClockType = {
|
|
150
|
-
install(): void,
|
|
151
|
-
mockDate(date: Date): void,
|
|
152
|
-
tick(milliseconds?: number): void,
|
|
153
|
-
uninstall(): void,
|
|
154
|
-
...
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
type JestMatcherResult = {
|
|
158
|
-
message?: string | (() => string),
|
|
159
|
-
pass: boolean,
|
|
160
|
-
...
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
type JestMatcher = (
|
|
164
|
-
received: any,
|
|
165
|
-
...actual: Array<any>
|
|
166
|
-
) => JestMatcherResult | Promise<JestMatcherResult>;
|
|
167
|
-
|
|
168
|
-
type JestPromiseType = {
|
|
169
|
-
/**
|
|
170
|
-
* Use rejects to unwrap the reason of a rejected promise so any other
|
|
171
|
-
* matcher can be chained. If the promise is fulfilled the assertion fails.
|
|
172
|
-
*/
|
|
173
|
-
rejects: JestExpectType,
|
|
174
|
-
/**
|
|
175
|
-
* Use resolves to unwrap the value of a fulfilled promise so any other
|
|
176
|
-
* matcher can be chained. If the promise is rejected the assertion fails.
|
|
177
|
-
*/
|
|
178
|
-
resolves: JestExpectType,
|
|
179
|
-
...
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Jest allows functions and classes to be used as test names in test() and
|
|
184
|
-
* describe()
|
|
185
|
-
*/
|
|
186
|
-
type JestTestName = string | Function;
|
|
187
|
-
|
|
188
|
-
type FakeableAPI =
|
|
189
|
-
| 'Date'
|
|
190
|
-
| 'hrtime'
|
|
191
|
-
| 'nextTick'
|
|
192
|
-
| 'performance'
|
|
193
|
-
| 'queueMicrotask'
|
|
194
|
-
| 'requestAnimationFrame'
|
|
195
|
-
| 'cancelAnimationFrame'
|
|
196
|
-
| 'requestIdleCallback'
|
|
197
|
-
| 'cancelIdleCallback'
|
|
198
|
-
| 'setImmediate'
|
|
199
|
-
| 'clearImmediate'
|
|
200
|
-
| 'setInterval'
|
|
201
|
-
| 'clearInterval'
|
|
202
|
-
| 'setTimeout'
|
|
203
|
-
| 'clearTimeout';
|
|
204
|
-
|
|
205
|
-
type FakeTimersConfig = {
|
|
206
|
-
advanceTimers?: boolean | number,
|
|
207
|
-
doNotFake?: Array<FakeableAPI>,
|
|
208
|
-
now?: number | Date,
|
|
209
|
-
timerLimit?: number,
|
|
210
|
-
legacyFakeTimers?: boolean,
|
|
211
|
-
...
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Plugin: jest-styled-components
|
|
216
|
-
*/
|
|
217
|
-
|
|
218
|
-
type JestStyledComponentsMatcherValue =
|
|
219
|
-
| string
|
|
220
|
-
| JestAsymmetricEqualityType
|
|
221
|
-
| RegExp
|
|
222
|
-
| typeof undefined;
|
|
223
|
-
|
|
224
|
-
type JestStyledComponentsMatcherOptions = {
|
|
225
|
-
media?: string,
|
|
226
|
-
modifier?: string,
|
|
227
|
-
supports?: string,
|
|
228
|
-
...
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
type JestStyledComponentsMatchersType = {
|
|
232
|
-
toHaveStyleRule(
|
|
233
|
-
property: string,
|
|
234
|
-
value: JestStyledComponentsMatcherValue,
|
|
235
|
-
options?: JestStyledComponentsMatcherOptions,
|
|
236
|
-
): void,
|
|
237
|
-
...
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Plugin: jest-enzyme
|
|
242
|
-
*/
|
|
243
|
-
type EnzymeMatchersType = {
|
|
244
|
-
// 5.x
|
|
245
|
-
toBeEmpty(): void,
|
|
246
|
-
toBePresent(): void,
|
|
247
|
-
// 6.x
|
|
248
|
-
toBeChecked(): void,
|
|
249
|
-
toBeDisabled(): void,
|
|
250
|
-
toBeEmptyRender(): void,
|
|
251
|
-
toContainMatchingElement(selector: string): void,
|
|
252
|
-
toContainMatchingElements(n: number, selector: string): void,
|
|
253
|
-
toContainExactlyOneMatchingElement(selector: string): void,
|
|
254
|
-
toContainReact(element: React.MixedElement): void,
|
|
255
|
-
toExist(): void,
|
|
256
|
-
toHaveClassName(className: string): void,
|
|
257
|
-
toHaveHTML(html: string): void,
|
|
258
|
-
toHaveProp: ((propKey: string, propValue?: any) => void) &
|
|
259
|
-
((props: {...}) => void),
|
|
260
|
-
toHaveRef(refName: string): void,
|
|
261
|
-
toHaveState: ((stateKey: string, stateValue?: any) => void) &
|
|
262
|
-
((state: {...}) => void),
|
|
263
|
-
toHaveStyle: ((styleKey: string, styleValue?: any) => void) &
|
|
264
|
-
((style: {...}) => void),
|
|
265
|
-
toHaveTagName(tagName: string): void,
|
|
266
|
-
toHaveText(text: string): void,
|
|
267
|
-
toHaveValue(value: any): void,
|
|
268
|
-
toIncludeText(text: string): void,
|
|
269
|
-
toMatchElement(
|
|
270
|
-
element: React.MixedElement,
|
|
271
|
-
options?: {ignoreProps?: boolean, verbose?: boolean},
|
|
272
|
-
): void,
|
|
273
|
-
toMatchSelector(selector: string): void,
|
|
274
|
-
// 7.x
|
|
275
|
-
toHaveDisplayName(name: string): void,
|
|
276
|
-
...
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
// DOM testing library extensions (jest-dom)
|
|
280
|
-
// https://github.com/testing-library/jest-dom
|
|
281
|
-
type DomTestingLibraryType = {
|
|
282
|
-
/**
|
|
283
|
-
* @deprecated
|
|
284
|
-
*/
|
|
285
|
-
toBeInTheDOM(container?: HTMLElement): void,
|
|
286
|
-
|
|
287
|
-
// 4.x
|
|
288
|
-
toBeInTheDocument(): void,
|
|
289
|
-
toBeVisible(): void,
|
|
290
|
-
toBeEmpty(): void,
|
|
291
|
-
toBeDisabled(): void,
|
|
292
|
-
toBeEnabled(): void,
|
|
293
|
-
toBeInvalid(): void,
|
|
294
|
-
toBeRequired(): void,
|
|
295
|
-
toBeValid(): void,
|
|
296
|
-
toContainElement(element: HTMLElement | null): void,
|
|
297
|
-
toContainHTML(htmlText: string): void,
|
|
298
|
-
toHaveAttribute(attr: string, value?: any): void,
|
|
299
|
-
toHaveClass(...classNames: string[]): void,
|
|
300
|
-
toHaveFocus(): void,
|
|
301
|
-
toHaveFormValues(expectedValues: {[name: string]: any, ...}): void,
|
|
302
|
-
toHaveStyle(css: string | {[name: string]: any, ...}): void,
|
|
303
|
-
toHaveTextContent(
|
|
304
|
-
text: string | RegExp,
|
|
305
|
-
options?: {normalizeWhitespace: boolean},
|
|
306
|
-
): void,
|
|
307
|
-
toHaveValue(value?: string | string[] | number): void,
|
|
308
|
-
|
|
309
|
-
// 5.x
|
|
310
|
-
toHaveDisplayValue(value: string | string[]): void,
|
|
311
|
-
toBeChecked(): void,
|
|
312
|
-
toBeEmptyDOMElement(): void,
|
|
313
|
-
toBePartiallyChecked(): void,
|
|
314
|
-
toHaveDescription(text: string | RegExp): void,
|
|
315
|
-
...
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
// Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers
|
|
319
|
-
type JestJQueryMatchersType = {
|
|
320
|
-
toExist(): void,
|
|
321
|
-
toHaveLength(len: number): void,
|
|
322
|
-
toHaveId(id: string): void,
|
|
323
|
-
toHaveClass(className: string): void,
|
|
324
|
-
toHaveTag(tag: string): void,
|
|
325
|
-
toHaveAttr(key: string, val?: any): void,
|
|
326
|
-
toHaveProp(key: string, val?: any): void,
|
|
327
|
-
toHaveText(text: string | RegExp): void,
|
|
328
|
-
toHaveData(key: string, val?: any): void,
|
|
329
|
-
toHaveValue(val: any): void,
|
|
330
|
-
toHaveCss(css: {[key: string]: any, ...}): void,
|
|
331
|
-
toBeChecked(): void,
|
|
332
|
-
toBeDisabled(): void,
|
|
333
|
-
toBeEmpty(): void,
|
|
334
|
-
toBeHidden(): void,
|
|
335
|
-
toBeSelected(): void,
|
|
336
|
-
toBeVisible(): void,
|
|
337
|
-
toBeFocused(): void,
|
|
338
|
-
toBeInDom(): void,
|
|
339
|
-
toBeMatchedBy(sel: string): void,
|
|
340
|
-
toHaveDescendant(sel: string): void,
|
|
341
|
-
toHaveDescendantWithText(sel: string, text: string | RegExp): void,
|
|
342
|
-
...
|
|
343
|
-
};
|
|
344
|
-
|
|
345
|
-
// Jest Extended Matchers: https://github.com/jest-community/jest-extended
|
|
346
|
-
type JestExtendedMatchersType = {
|
|
347
|
-
/**
|
|
348
|
-
* Note: Currently unimplemented
|
|
349
|
-
* Passing assertion
|
|
350
|
-
*
|
|
351
|
-
* @param {String} message
|
|
352
|
-
*/
|
|
353
|
-
// pass(message: string): void;
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Note: Currently unimplemented
|
|
357
|
-
* Failing assertion
|
|
358
|
-
*
|
|
359
|
-
* @param {String} message
|
|
360
|
-
*/
|
|
361
|
-
// fail(message: string): void;
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty.
|
|
365
|
-
*/
|
|
366
|
-
toBeEmpty(): void,
|
|
367
|
-
/**
|
|
368
|
-
* Use .toBeOneOf when checking if a value is a member of a given Array.
|
|
369
|
-
* @param {Array.<*>} members
|
|
370
|
-
*/
|
|
371
|
-
toBeOneOf(members: any[]): void,
|
|
372
|
-
/**
|
|
373
|
-
* Use `.toBeNil` when checking a value is `null` or `undefined`.
|
|
374
|
-
*/
|
|
375
|
-
toBeNil(): void,
|
|
376
|
-
/**
|
|
377
|
-
* Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`.
|
|
378
|
-
* @param {Function} predicate
|
|
379
|
-
*/
|
|
380
|
-
toSatisfy(predicate: (n: any) => boolean): void,
|
|
381
|
-
/**
|
|
382
|
-
* Use `.toBeArray` when checking if a value is an `Array`.
|
|
383
|
-
*/
|
|
384
|
-
toBeArray(): void,
|
|
385
|
-
/**
|
|
386
|
-
* Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x.
|
|
387
|
-
* @param {Number} x
|
|
388
|
-
*/
|
|
389
|
-
toBeArrayOfSize(x: number): void,
|
|
390
|
-
/**
|
|
391
|
-
* Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set.
|
|
392
|
-
* @param {Array.<*>} members
|
|
393
|
-
*/
|
|
394
|
-
toIncludeAllMembers(members: any[]): void,
|
|
395
|
-
/**
|
|
396
|
-
* Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set.
|
|
397
|
-
* @param {Array.<*>} members
|
|
398
|
-
*/
|
|
399
|
-
toIncludeAnyMembers(members: any[]): void,
|
|
400
|
-
/**
|
|
401
|
-
* Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array.
|
|
402
|
-
* @param {Function} predicate
|
|
403
|
-
*/
|
|
404
|
-
toSatisfyAll(predicate: (n: any) => boolean): void,
|
|
405
|
-
/**
|
|
406
|
-
* Use `.toBeBoolean` when checking if a value is a `Boolean`.
|
|
407
|
-
*/
|
|
408
|
-
toBeBoolean(): void,
|
|
409
|
-
/**
|
|
410
|
-
* Use `.toBeTrue` when checking a value is equal (===) to `true`.
|
|
411
|
-
*/
|
|
412
|
-
toBeTrue(): void,
|
|
413
|
-
/**
|
|
414
|
-
* Use `.toBeFalse` when checking a value is equal (===) to `false`.
|
|
415
|
-
*/
|
|
416
|
-
toBeFalse(): void,
|
|
417
|
-
/**
|
|
418
|
-
* Use .toBeDate when checking if a value is a Date.
|
|
419
|
-
*/
|
|
420
|
-
toBeDate(): void,
|
|
421
|
-
/**
|
|
422
|
-
* Use `.toBeFunction` when checking if a value is a `Function`.
|
|
423
|
-
*/
|
|
424
|
-
toBeFunction(): void,
|
|
425
|
-
/**
|
|
426
|
-
* Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`.
|
|
427
|
-
*
|
|
428
|
-
* Note: Required Jest version >22
|
|
429
|
-
* Note: Your mock functions will have to be asynchronous to cause the timestamps inside of Jest to occur in a differentJS event loop, otherwise the mock timestamps will all be the same
|
|
430
|
-
*
|
|
431
|
-
* @param {Mock} mock
|
|
432
|
-
*/
|
|
433
|
-
toHaveBeenCalledBefore(mock: JestMockFn<any, any>): void,
|
|
434
|
-
/**
|
|
435
|
-
* Use `.toBeNumber` when checking if a value is a `Number`.
|
|
436
|
-
*/
|
|
437
|
-
toBeNumber(): void,
|
|
438
|
-
/**
|
|
439
|
-
* Use `.toBeNaN` when checking a value is `NaN`.
|
|
440
|
-
*/
|
|
441
|
-
toBeNaN(): void,
|
|
442
|
-
/**
|
|
443
|
-
* Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`.
|
|
444
|
-
*/
|
|
445
|
-
toBeFinite(): void,
|
|
446
|
-
/**
|
|
447
|
-
* Use `.toBePositive` when checking if a value is a positive `Number`.
|
|
448
|
-
*/
|
|
449
|
-
toBePositive(): void,
|
|
450
|
-
/**
|
|
451
|
-
* Use `.toBeNegative` when checking if a value is a negative `Number`.
|
|
452
|
-
*/
|
|
453
|
-
toBeNegative(): void,
|
|
454
|
-
/**
|
|
455
|
-
* Use `.toBeEven` when checking if a value is an even `Number`.
|
|
456
|
-
*/
|
|
457
|
-
toBeEven(): void,
|
|
458
|
-
/**
|
|
459
|
-
* Use `.toBeOdd` when checking if a value is an odd `Number`.
|
|
460
|
-
*/
|
|
461
|
-
toBeOdd(): void,
|
|
462
|
-
/**
|
|
463
|
-
* Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive).
|
|
464
|
-
*
|
|
465
|
-
* @param {Number} start
|
|
466
|
-
* @param {Number} end
|
|
467
|
-
*/
|
|
468
|
-
toBeWithin(start: number, end: number): void,
|
|
469
|
-
/**
|
|
470
|
-
* Use `.toBeObject` when checking if a value is an `Object`.
|
|
471
|
-
*/
|
|
472
|
-
toBeObject(): void,
|
|
473
|
-
/**
|
|
474
|
-
* Use `.toContainKey` when checking if an object contains the provided key.
|
|
475
|
-
*
|
|
476
|
-
* @param {String} key
|
|
477
|
-
*/
|
|
478
|
-
toContainKey(key: string): void,
|
|
479
|
-
/**
|
|
480
|
-
* Use `.toContainKeys` when checking if an object has all of the provided keys.
|
|
481
|
-
*
|
|
482
|
-
* @param {Array.<String>} keys
|
|
483
|
-
*/
|
|
484
|
-
toContainKeys(keys: string[]): void,
|
|
485
|
-
/**
|
|
486
|
-
* Use `.toContainAllKeys` when checking if an object only contains all of the provided keys.
|
|
487
|
-
*
|
|
488
|
-
* @param {Array.<String>} keys
|
|
489
|
-
*/
|
|
490
|
-
toContainAllKeys(keys: string[]): void,
|
|
491
|
-
/**
|
|
492
|
-
* Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys.
|
|
493
|
-
*
|
|
494
|
-
* @param {Array.<String>} keys
|
|
495
|
-
*/
|
|
496
|
-
toContainAnyKeys(keys: string[]): void,
|
|
497
|
-
/**
|
|
498
|
-
* Use `.toContainValue` when checking if an object contains the provided value.
|
|
499
|
-
*
|
|
500
|
-
* @param {*} value
|
|
501
|
-
*/
|
|
502
|
-
toContainValue(value: any): void,
|
|
503
|
-
/**
|
|
504
|
-
* Use `.toContainValues` when checking if an object contains all of the provided values.
|
|
505
|
-
*
|
|
506
|
-
* @param {Array.<*>} values
|
|
507
|
-
*/
|
|
508
|
-
toContainValues(values: any[]): void,
|
|
509
|
-
/**
|
|
510
|
-
* Use `.toContainAllValues` when checking if an object only contains all of the provided values.
|
|
511
|
-
*
|
|
512
|
-
* @param {Array.<*>} values
|
|
513
|
-
*/
|
|
514
|
-
toContainAllValues(values: any[]): void,
|
|
515
|
-
/**
|
|
516
|
-
* Use `.toContainAnyValues` when checking if an object contains at least one of the provided values.
|
|
517
|
-
*
|
|
518
|
-
* @param {Array.<*>} values
|
|
519
|
-
*/
|
|
520
|
-
toContainAnyValues(values: any[]): void,
|
|
521
|
-
/**
|
|
522
|
-
* Use `.toContainEntry` when checking if an object contains the provided entry.
|
|
523
|
-
*
|
|
524
|
-
* @param {Array.<String, String>} entry
|
|
525
|
-
*/
|
|
526
|
-
toContainEntry(entry: [string, string]): void,
|
|
527
|
-
/**
|
|
528
|
-
* Use `.toContainEntries` when checking if an object contains all of the provided entries.
|
|
529
|
-
*
|
|
530
|
-
* @param {Array.<Array.<String, String>>} entries
|
|
531
|
-
*/
|
|
532
|
-
toContainEntries(entries: [string, string][]): void,
|
|
533
|
-
/**
|
|
534
|
-
* Use `.toContainAllEntries` when checking if an object only contains all of the provided entries.
|
|
535
|
-
*
|
|
536
|
-
* @param {Array.<Array.<String, String>>} entries
|
|
537
|
-
*/
|
|
538
|
-
toContainAllEntries(entries: [string, string][]): void,
|
|
539
|
-
/**
|
|
540
|
-
* Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries.
|
|
541
|
-
*
|
|
542
|
-
* @param {Array.<Array.<String, String>>} entries
|
|
543
|
-
*/
|
|
544
|
-
toContainAnyEntries(entries: [string, string][]): void,
|
|
545
|
-
/**
|
|
546
|
-
* Use `.toBeExtensible` when checking if an object is extensible.
|
|
547
|
-
*/
|
|
548
|
-
toBeExtensible(): void,
|
|
549
|
-
/**
|
|
550
|
-
* Use `.toBeFrozen` when checking if an object is frozen.
|
|
551
|
-
*/
|
|
552
|
-
toBeFrozen(): void,
|
|
553
|
-
/**
|
|
554
|
-
* Use `.toBeSealed` when checking if an object is sealed.
|
|
555
|
-
*/
|
|
556
|
-
toBeSealed(): void,
|
|
557
|
-
/**
|
|
558
|
-
* Use `.toBeString` when checking if a value is a `String`.
|
|
559
|
-
*/
|
|
560
|
-
toBeString(): void,
|
|
561
|
-
/**
|
|
562
|
-
* Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings.
|
|
563
|
-
*
|
|
564
|
-
* @param {String} string
|
|
565
|
-
*/
|
|
566
|
-
toEqualCaseInsensitive(string: string): void,
|
|
567
|
-
/**
|
|
568
|
-
* Use `.toStartWith` when checking if a `String` starts with a given `String` prefix.
|
|
569
|
-
*
|
|
570
|
-
* @param {String} prefix
|
|
571
|
-
*/
|
|
572
|
-
toStartWith(prefix: string): void,
|
|
573
|
-
/**
|
|
574
|
-
* Use `.toEndWith` when checking if a `String` ends with a given `String` suffix.
|
|
575
|
-
*
|
|
576
|
-
* @param {String} suffix
|
|
577
|
-
*/
|
|
578
|
-
toEndWith(suffix: string): void,
|
|
579
|
-
/**
|
|
580
|
-
* Use `.toInclude` when checking if a `String` includes the given `String` substring.
|
|
581
|
-
*
|
|
582
|
-
* @param {String} substring
|
|
583
|
-
*/
|
|
584
|
-
toInclude(substring: string): void,
|
|
585
|
-
/**
|
|
586
|
-
* Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times.
|
|
587
|
-
*
|
|
588
|
-
* @param {String} substring
|
|
589
|
-
* @param {Number} times
|
|
590
|
-
*/
|
|
591
|
-
toIncludeRepeated(substring: string, times: number): void,
|
|
592
|
-
/**
|
|
593
|
-
* Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings.
|
|
594
|
-
*
|
|
595
|
-
* @param {Array.<String>} substring
|
|
596
|
-
*/
|
|
597
|
-
toIncludeMultiple(substring: string[]): void,
|
|
598
|
-
...
|
|
599
|
-
};
|
|
600
|
-
|
|
601
|
-
// Diffing snapshot utility for Jest (snapshot-diff)
|
|
602
|
-
// https://github.com/jest-community/snapshot-diff
|
|
603
|
-
type SnapshotDiffType = {
|
|
604
|
-
/**
|
|
605
|
-
* Compare the difference between the actual in the `expect()`
|
|
606
|
-
* vs the object inside `valueB` with some extra options.
|
|
607
|
-
*/
|
|
608
|
-
toMatchDiffSnapshot(
|
|
609
|
-
valueB: any,
|
|
610
|
-
options?: {
|
|
611
|
-
expand?: boolean,
|
|
612
|
-
colors?: boolean,
|
|
613
|
-
contextLines?: number,
|
|
614
|
-
stablePatchmarks?: boolean,
|
|
615
|
-
aAnnotation?: string,
|
|
616
|
-
bAnnotation?: string,
|
|
617
|
-
},
|
|
618
|
-
testName?: string,
|
|
619
|
-
): void,
|
|
620
|
-
...
|
|
621
|
-
};
|
|
622
|
-
|
|
623
|
-
interface JestExpectType {
|
|
624
|
-
not: JestExpectType &
|
|
625
|
-
EnzymeMatchersType &
|
|
626
|
-
DomTestingLibraryType &
|
|
627
|
-
JestJQueryMatchersType &
|
|
628
|
-
JestStyledComponentsMatchersType &
|
|
629
|
-
JestExtendedMatchersType &
|
|
630
|
-
SnapshotDiffType;
|
|
631
|
-
/**
|
|
632
|
-
* If you have a mock function, you can use .lastCalledWith to test what
|
|
633
|
-
* arguments it was last called with.
|
|
634
|
-
*/
|
|
635
|
-
lastCalledWith(...args: Array<any>): void;
|
|
636
|
-
/**
|
|
637
|
-
* toBe just checks that a value is what you expect. It uses === to check
|
|
638
|
-
* strict equality.
|
|
639
|
-
*/
|
|
640
|
-
toBe(value: any): void;
|
|
641
|
-
/**
|
|
642
|
-
* Use .toBeCalledWith to ensure that a mock function was called with
|
|
643
|
-
* specific arguments.
|
|
644
|
-
*/
|
|
645
|
-
toBeCalledWith(...args: Array<any>): void;
|
|
646
|
-
/**
|
|
647
|
-
* Using exact equality with floating point numbers is a bad idea. Rounding
|
|
648
|
-
* means that intuitive things fail.
|
|
649
|
-
*/
|
|
650
|
-
toBeCloseTo(num: number, delta: any): void;
|
|
651
|
-
/**
|
|
652
|
-
* Use .toBeDefined to check that a variable is not undefined.
|
|
653
|
-
*/
|
|
654
|
-
toBeDefined(): void;
|
|
655
|
-
/**
|
|
656
|
-
* Use .toBeFalsy when you don't care what a value is, you just want to
|
|
657
|
-
* ensure a value is false in a boolean context.
|
|
658
|
-
*/
|
|
659
|
-
toBeFalsy(): void;
|
|
660
|
-
/**
|
|
661
|
-
* To compare floating point numbers, you can use toBeGreaterThan.
|
|
662
|
-
*/
|
|
663
|
-
toBeGreaterThan(number: number): void;
|
|
664
|
-
/**
|
|
665
|
-
* To compare floating point numbers, you can use toBeGreaterThanOrEqual.
|
|
666
|
-
*/
|
|
667
|
-
toBeGreaterThanOrEqual(number: number): void;
|
|
668
|
-
/**
|
|
669
|
-
* To compare floating point numbers, you can use toBeLessThan.
|
|
670
|
-
*/
|
|
671
|
-
toBeLessThan(number: number): void;
|
|
672
|
-
/**
|
|
673
|
-
* To compare floating point numbers, you can use toBeLessThanOrEqual.
|
|
674
|
-
*/
|
|
675
|
-
toBeLessThanOrEqual(number: number): void;
|
|
676
|
-
/**
|
|
677
|
-
* Use .toBeInstanceOf(Class) to check that an object is an instance of a
|
|
678
|
-
* class.
|
|
679
|
-
*/
|
|
680
|
-
toBeInstanceOf(cls: Class<any>): void;
|
|
681
|
-
/**
|
|
682
|
-
* .toBeNull() is the same as .toBe(null) but the error messages are a bit
|
|
683
|
-
* nicer.
|
|
684
|
-
*/
|
|
685
|
-
toBeNull(): void;
|
|
686
|
-
/**
|
|
687
|
-
* Use .toBeTruthy when you don't care what a value is, you just want to
|
|
688
|
-
* ensure a value is true in a boolean context.
|
|
689
|
-
*/
|
|
690
|
-
toBeTruthy(): void;
|
|
691
|
-
/**
|
|
692
|
-
* Use .toBeUndefined to check that a variable is undefined.
|
|
693
|
-
*/
|
|
694
|
-
toBeUndefined(): void;
|
|
695
|
-
/**
|
|
696
|
-
* Use .toContain when you want to check that an item is in a list. For
|
|
697
|
-
* testing the items in the list, this uses ===, a strict equality check.
|
|
698
|
-
*/
|
|
699
|
-
toContain(item: any): void;
|
|
700
|
-
/**
|
|
701
|
-
* Use .toContainEqual when you want to check that an item is in a list. For
|
|
702
|
-
* testing the items in the list, this matcher recursively checks the
|
|
703
|
-
* equality of all fields, rather than checking for object identity.
|
|
704
|
-
*/
|
|
705
|
-
toContainEqual(item: any): void;
|
|
706
|
-
/**
|
|
707
|
-
* Use .toEqual when you want to check that two objects have the same value.
|
|
708
|
-
* This matcher recursively checks the equality of all fields, rather than
|
|
709
|
-
* checking for object identity.
|
|
710
|
-
*/
|
|
711
|
-
toEqual(value: any): void;
|
|
712
|
-
/**
|
|
713
|
-
* Use .toHaveBeenCalled to ensure that a mock function got called.
|
|
714
|
-
*/
|
|
715
|
-
toHaveBeenCalled(): void;
|
|
716
|
-
toBeCalled(): void;
|
|
717
|
-
/**
|
|
718
|
-
* Use .toHaveBeenCalledTimes to ensure that a mock function got called exact
|
|
719
|
-
* number of times.
|
|
720
|
-
*/
|
|
721
|
-
toHaveBeenCalledTimes(number: number): void;
|
|
722
|
-
toBeCalledTimes(number: number): void;
|
|
723
|
-
/**
|
|
724
|
-
*
|
|
725
|
-
*/
|
|
726
|
-
toHaveBeenNthCalledWith(nthCall: number, ...args: Array<any>): void;
|
|
727
|
-
nthCalledWith(nthCall: number, ...args: Array<any>): void;
|
|
728
|
-
/**
|
|
729
|
-
*
|
|
730
|
-
*/
|
|
731
|
-
toHaveReturned(): void;
|
|
732
|
-
toReturn(): void;
|
|
733
|
-
/**
|
|
734
|
-
*
|
|
735
|
-
*/
|
|
736
|
-
toHaveReturnedTimes(number: number): void;
|
|
737
|
-
toReturnTimes(number: number): void;
|
|
738
|
-
/**
|
|
739
|
-
*
|
|
740
|
-
*/
|
|
741
|
-
toHaveReturnedWith(value: any): void;
|
|
742
|
-
toReturnWith(value: any): void;
|
|
743
|
-
/**
|
|
744
|
-
*
|
|
745
|
-
*/
|
|
746
|
-
toHaveLastReturnedWith(value: any): void;
|
|
747
|
-
lastReturnedWith(value: any): void;
|
|
748
|
-
/**
|
|
749
|
-
*
|
|
750
|
-
*/
|
|
751
|
-
toHaveNthReturnedWith(nthCall: number, value: any): void;
|
|
752
|
-
nthReturnedWith(nthCall: number, value: any): void;
|
|
753
|
-
/**
|
|
754
|
-
* Use .toHaveBeenCalledWith to ensure that a mock function was called with
|
|
755
|
-
* specific arguments.
|
|
756
|
-
*/
|
|
757
|
-
toHaveBeenCalledWith(...args: Array<any>): void;
|
|
758
|
-
toBeCalledWith(...args: Array<any>): void;
|
|
759
|
-
/**
|
|
760
|
-
* Use .toHaveBeenLastCalledWith to ensure that a mock function was last called
|
|
761
|
-
* with specific arguments.
|
|
762
|
-
*/
|
|
763
|
-
toHaveBeenLastCalledWith(...args: Array<any>): void;
|
|
764
|
-
lastCalledWith(...args: Array<any>): void;
|
|
765
|
-
/**
|
|
766
|
-
* Check that an object has a .length property and it is set to a certain
|
|
767
|
-
* numeric value.
|
|
768
|
-
*/
|
|
769
|
-
toHaveLength(number: number): void;
|
|
770
|
-
/**
|
|
771
|
-
*
|
|
772
|
-
*/
|
|
773
|
-
toHaveProperty(propPath: string | $ReadOnlyArray<string>, value?: any): void;
|
|
774
|
-
/**
|
|
775
|
-
* Use .toMatch to check that a string matches a regular expression or string.
|
|
776
|
-
*/
|
|
777
|
-
toMatch(regexpOrString: RegExp | string): void;
|
|
778
|
-
/**
|
|
779
|
-
* Use .toMatchObject to check that a javascript object matches a subset of the properties of an object.
|
|
780
|
-
*/
|
|
781
|
-
toMatchObject(object: Object | Array<Object>): void;
|
|
782
|
-
/**
|
|
783
|
-
* Use .toStrictEqual to check that a javascript object matches a subset of the properties of an object.
|
|
784
|
-
*/
|
|
785
|
-
toStrictEqual(value: any): void;
|
|
786
|
-
/**
|
|
787
|
-
* This ensures that an Object matches the most recent snapshot.
|
|
788
|
-
*/
|
|
789
|
-
toMatchSnapshot(propertyMatchers?: any, name?: string): void;
|
|
790
|
-
/**
|
|
791
|
-
* This ensures that an Object matches the most recent snapshot.
|
|
792
|
-
*/
|
|
793
|
-
toMatchSnapshot(name: string): void;
|
|
794
|
-
|
|
795
|
-
toMatchInlineSnapshot(snapshot?: string): void;
|
|
796
|
-
toMatchInlineSnapshot(propertyMatchers?: any, snapshot?: string): void;
|
|
797
|
-
/**
|
|
798
|
-
* Use .toThrow to test that a function throws when it is called.
|
|
799
|
-
* If you want to test that a specific error gets thrown, you can provide an
|
|
800
|
-
* argument to toThrow. The argument can be a string for the error message,
|
|
801
|
-
* a class for the error, or a regex that should match the error.
|
|
802
|
-
*
|
|
803
|
-
* Alias: .toThrowError
|
|
804
|
-
*/
|
|
805
|
-
toThrow(message?: string | Error | Class<Error> | RegExp): void;
|
|
806
|
-
toThrowError(message?: string | Error | Class<Error> | RegExp): void;
|
|
807
|
-
/**
|
|
808
|
-
* Use .toThrowErrorMatchingSnapshot to test that a function throws a error
|
|
809
|
-
* matching the most recent snapshot when it is called.
|
|
810
|
-
*/
|
|
811
|
-
toThrowErrorMatchingSnapshot(): void;
|
|
812
|
-
toThrowErrorMatchingInlineSnapshot(snapshot?: string): void;
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
type JestObjectType = {
|
|
816
|
-
/**
|
|
817
|
-
* Disables automatic mocking in the module loader.
|
|
818
|
-
*
|
|
819
|
-
* After this method is called, all `require()`s will return the real
|
|
820
|
-
* versions of each module (rather than a mocked version).
|
|
821
|
-
*/
|
|
822
|
-
disableAutomock(): JestObjectType,
|
|
823
|
-
/**
|
|
824
|
-
* An un-hoisted version of disableAutomock
|
|
825
|
-
*/
|
|
826
|
-
autoMockOff(): JestObjectType,
|
|
827
|
-
/**
|
|
828
|
-
* Enables automatic mocking in the module loader.
|
|
829
|
-
*/
|
|
830
|
-
enableAutomock(): JestObjectType,
|
|
831
|
-
/**
|
|
832
|
-
* An un-hoisted version of enableAutomock
|
|
833
|
-
*/
|
|
834
|
-
autoMockOn(): JestObjectType,
|
|
835
|
-
/**
|
|
836
|
-
* Clears the mock.calls and mock.instances properties of all mocks.
|
|
837
|
-
* Equivalent to calling .mockClear() on every mocked function.
|
|
838
|
-
*/
|
|
839
|
-
clearAllMocks(): JestObjectType,
|
|
840
|
-
/**
|
|
841
|
-
* Resets the state of all mocks. Equivalent to calling .mockReset() on every
|
|
842
|
-
* mocked function.
|
|
843
|
-
*/
|
|
844
|
-
resetAllMocks(): JestObjectType,
|
|
845
|
-
/**
|
|
846
|
-
* Restores all mocks back to their original value.
|
|
847
|
-
*/
|
|
848
|
-
restoreAllMocks(): JestObjectType,
|
|
849
|
-
/**
|
|
850
|
-
* Removes any pending timers from the timer system.
|
|
851
|
-
*/
|
|
852
|
-
clearAllTimers(): void,
|
|
853
|
-
/**
|
|
854
|
-
* Returns the number of fake timers still left to run.
|
|
855
|
-
*/
|
|
856
|
-
getTimerCount(): number,
|
|
857
|
-
/**
|
|
858
|
-
* Set the current system time used by fake timers.
|
|
859
|
-
* Simulates a user changing the system clock while your program is running.
|
|
860
|
-
* It affects the current time but it does not in itself cause
|
|
861
|
-
* e.g. timers to fire; they will fire exactly as they would have done
|
|
862
|
-
* without the call to jest.setSystemTime().
|
|
863
|
-
*/
|
|
864
|
-
setSystemTime(now?: number | Date): void,
|
|
865
|
-
/**
|
|
866
|
-
* The same as `mock` but not moved to the top of the expectation by
|
|
867
|
-
* babel-jest.
|
|
868
|
-
*/
|
|
869
|
-
doMock(moduleName: string, moduleFactory?: any): JestObjectType,
|
|
870
|
-
/**
|
|
871
|
-
* The same as `unmock` but not moved to the top of the expectation by
|
|
872
|
-
* babel-jest.
|
|
873
|
-
*/
|
|
874
|
-
dontMock(moduleName: string): JestObjectType,
|
|
875
|
-
/**
|
|
876
|
-
* Returns a new, unused mock function. Optionally takes a mock
|
|
877
|
-
* implementation.
|
|
878
|
-
*/
|
|
879
|
-
// MODIFIED: Added defaults to type arguments.
|
|
880
|
-
fn<TArguments: $ReadOnlyArray<mixed> = $ReadOnlyArray<any>, TReturn = any>(
|
|
881
|
-
implementation?: (...args: TArguments) => TReturn,
|
|
882
|
-
): JestMockFn<TArguments, TReturn>,
|
|
883
|
-
/**
|
|
884
|
-
* Determines if the given function is a mocked function.
|
|
885
|
-
*/
|
|
886
|
-
isMockFunction(fn: Function): boolean,
|
|
887
|
-
/**
|
|
888
|
-
* Alias of `createMockFromModule`.
|
|
889
|
-
*/
|
|
890
|
-
genMockFromModule(moduleName: string): any,
|
|
891
|
-
/**
|
|
892
|
-
* Given the name of a module, use the automatic mocking system to generate a
|
|
893
|
-
* mocked version of the module for you.
|
|
894
|
-
*/
|
|
895
|
-
createMockFromModule(moduleName: string): any,
|
|
896
|
-
/**
|
|
897
|
-
* Mocks a module with an auto-mocked version when it is being required.
|
|
898
|
-
*
|
|
899
|
-
* The second argument can be used to specify an explicit module factory that
|
|
900
|
-
* is being run instead of using Jest's automocking feature.
|
|
901
|
-
*
|
|
902
|
-
* The third argument can be used to create virtual mocks -- mocks of modules
|
|
903
|
-
* that don't exist anywhere in the system.
|
|
904
|
-
*/
|
|
905
|
-
mock(
|
|
906
|
-
moduleName: string,
|
|
907
|
-
moduleFactory?: any,
|
|
908
|
-
options?: Object,
|
|
909
|
-
): JestObjectType,
|
|
910
|
-
/**
|
|
911
|
-
* Returns the actual module instead of a mock, bypassing all checks on
|
|
912
|
-
* whether the module should receive a mock implementation or not.
|
|
913
|
-
*/
|
|
914
|
-
requireActual<T>(m: $Flow$ModuleRef<T> | string): T,
|
|
915
|
-
/**
|
|
916
|
-
* Returns a mock module instead of the actual module, bypassing all checks
|
|
917
|
-
* on whether the module should be required normally or not.
|
|
918
|
-
*/
|
|
919
|
-
requireMock(moduleName: string): any,
|
|
920
|
-
/**
|
|
921
|
-
* Resets the module registry - the cache of all required modules. This is
|
|
922
|
-
* useful to isolate modules where local state might conflict between tests.
|
|
923
|
-
*/
|
|
924
|
-
resetModules(): JestObjectType,
|
|
925
|
-
/**
|
|
926
|
-
* Creates a sandbox registry for the modules that are loaded inside the
|
|
927
|
-
* callback function. This is useful to isolate specific modules for every
|
|
928
|
-
* test so that local module state doesn't conflict between tests.
|
|
929
|
-
*/
|
|
930
|
-
isolateModules(fn: () => void): JestObjectType,
|
|
931
|
-
/**
|
|
932
|
-
* Exhausts the micro-task queue (usually interfaced in node via
|
|
933
|
-
* process.nextTick).
|
|
934
|
-
*/
|
|
935
|
-
runAllTicks(): void,
|
|
936
|
-
/**
|
|
937
|
-
* Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(),
|
|
938
|
-
* setInterval(), and setImmediate()).
|
|
939
|
-
*/
|
|
940
|
-
runAllTimers(): void,
|
|
941
|
-
/**
|
|
942
|
-
* Exhausts all tasks queued by setImmediate().
|
|
943
|
-
*/
|
|
944
|
-
runAllImmediates(): void,
|
|
945
|
-
/**
|
|
946
|
-
* Executes only the macro task queue (i.e. all tasks queued by setTimeout()
|
|
947
|
-
* or setInterval() and setImmediate()).
|
|
948
|
-
*/
|
|
949
|
-
advanceTimersByTime(msToRun: number): void,
|
|
950
|
-
/**
|
|
951
|
-
* Executes only the macro-tasks that are currently pending (i.e., only the
|
|
952
|
-
* tasks that have been queued by setTimeout() or setInterval() up to this
|
|
953
|
-
* point)
|
|
954
|
-
*/
|
|
955
|
-
runOnlyPendingTimers(): void,
|
|
956
|
-
/**
|
|
957
|
-
* Explicitly supplies the mock object that the module system should return
|
|
958
|
-
* for the specified module. Note: It is recommended to use jest.mock()
|
|
959
|
-
* instead.
|
|
960
|
-
*/
|
|
961
|
-
setMock(moduleName: string, moduleExports: any): JestObjectType,
|
|
962
|
-
/**
|
|
963
|
-
* Indicates that the module system should never return a mocked version of
|
|
964
|
-
* the specified module from require() (e.g. that it should always return the
|
|
965
|
-
* real module).
|
|
966
|
-
*/
|
|
967
|
-
unmock(moduleName: string): JestObjectType,
|
|
968
|
-
/**
|
|
969
|
-
* Instructs Jest to use fake versions of the standard timer functions
|
|
970
|
-
* (setTimeout, setInterval, clearTimeout, clearInterval, nextTick,
|
|
971
|
-
* setImmediate and clearImmediate).
|
|
972
|
-
*/
|
|
973
|
-
useFakeTimers(fakeTimersConfig?: FakeTimersConfig): JestObjectType,
|
|
974
|
-
/**
|
|
975
|
-
* Instructs Jest to use the real versions of the standard timer functions.
|
|
976
|
-
*/
|
|
977
|
-
useRealTimers(): JestObjectType,
|
|
978
|
-
/**
|
|
979
|
-
* Creates a mock function similar to jest.fn but also tracks calls to
|
|
980
|
-
* object[methodName].
|
|
981
|
-
*/
|
|
982
|
-
spyOn(
|
|
983
|
-
object: Object,
|
|
984
|
-
methodName: string,
|
|
985
|
-
accessType?: 'get' | 'set',
|
|
986
|
-
): JestMockFn<any, any>,
|
|
987
|
-
/**
|
|
988
|
-
* Set the default timeout interval for tests and before/after hooks in milliseconds.
|
|
989
|
-
* Note: The default timeout interval is 5 seconds if this method is not called.
|
|
990
|
-
*/
|
|
991
|
-
setTimeout(timeout: number): JestObjectType,
|
|
992
|
-
...
|
|
993
|
-
};
|
|
994
|
-
|
|
995
|
-
type JestSpyType = {calls: JestCallsType, ...};
|
|
996
|
-
|
|
997
|
-
type JestDoneFn = {
|
|
998
|
-
(error?: Error): void,
|
|
999
|
-
fail: (error: Error) => void,
|
|
1000
|
-
};
|
|
1001
|
-
|
|
1002
|
-
/** Runs this function after every test inside this context */
|
|
1003
|
-
declare function afterEach(
|
|
1004
|
-
fn: (done: JestDoneFn) => ?Promise<mixed>,
|
|
1005
|
-
timeout?: number,
|
|
1006
|
-
): void;
|
|
1007
|
-
/** Runs this function before every test inside this context */
|
|
1008
|
-
declare function beforeEach(
|
|
1009
|
-
fn: (done: JestDoneFn) => ?Promise<mixed>,
|
|
1010
|
-
timeout?: number,
|
|
1011
|
-
): void;
|
|
1012
|
-
/** Runs this function after all tests have finished inside this context */
|
|
1013
|
-
declare function afterAll(
|
|
1014
|
-
fn: (done: JestDoneFn) => ?Promise<mixed>,
|
|
1015
|
-
timeout?: number,
|
|
1016
|
-
): void;
|
|
1017
|
-
/** Runs this function before any tests have started inside this context */
|
|
1018
|
-
declare function beforeAll(
|
|
1019
|
-
fn: (done: JestDoneFn) => ?Promise<mixed>,
|
|
1020
|
-
timeout?: number,
|
|
1021
|
-
): void;
|
|
1022
|
-
|
|
1023
|
-
/** A context for grouping tests together */
|
|
1024
|
-
declare var describe: {
|
|
1025
|
-
/**
|
|
1026
|
-
* Creates a block that groups together several related tests in one "test suite"
|
|
1027
|
-
*/
|
|
1028
|
-
(name: JestTestName, fn: () => void): void,
|
|
1029
|
-
/**
|
|
1030
|
-
* Only run this describe block
|
|
1031
|
-
*/
|
|
1032
|
-
only(name: JestTestName, fn: () => void): void,
|
|
1033
|
-
/**
|
|
1034
|
-
* Skip running this describe block
|
|
1035
|
-
*/
|
|
1036
|
-
skip(name: JestTestName, fn: () => void): void,
|
|
1037
|
-
/**
|
|
1038
|
-
* each runs this test against array of argument arrays per each run
|
|
1039
|
-
*
|
|
1040
|
-
* @param {table} table of Test
|
|
1041
|
-
*/
|
|
1042
|
-
each(
|
|
1043
|
-
...table: Array<Array<mixed> | mixed> | [Array<string>, string]
|
|
1044
|
-
): (
|
|
1045
|
-
name: JestTestName,
|
|
1046
|
-
fn?: (...args: Array<any>) => ?Promise<mixed>,
|
|
1047
|
-
timeout?: number,
|
|
1048
|
-
) => void,
|
|
1049
|
-
...
|
|
1050
|
-
};
|
|
1051
|
-
|
|
1052
|
-
/** An individual test unit */
|
|
1053
|
-
declare var it: {
|
|
1054
|
-
/**
|
|
1055
|
-
* An individual test unit
|
|
1056
|
-
*
|
|
1057
|
-
* @param {JestTestName} Name of Test
|
|
1058
|
-
* @param {Function} Test
|
|
1059
|
-
* @param {number} Timeout for the test, in milliseconds.
|
|
1060
|
-
*/
|
|
1061
|
-
(
|
|
1062
|
-
name: JestTestName,
|
|
1063
|
-
fn?: (done: JestDoneFn) => ?Promise<mixed>,
|
|
1064
|
-
timeout?: number,
|
|
1065
|
-
): void,
|
|
1066
|
-
/**
|
|
1067
|
-
* Only run this test
|
|
1068
|
-
*
|
|
1069
|
-
* @param {JestTestName} Name of Test
|
|
1070
|
-
* @param {Function} Test
|
|
1071
|
-
* @param {number} Timeout for the test, in milliseconds.
|
|
1072
|
-
*/
|
|
1073
|
-
only: {
|
|
1074
|
-
(
|
|
1075
|
-
name: JestTestName,
|
|
1076
|
-
fn?: (done: JestDoneFn) => ?Promise<mixed>,
|
|
1077
|
-
timeout?: number,
|
|
1078
|
-
): void,
|
|
1079
|
-
each(
|
|
1080
|
-
...table: Array<Array<mixed> | mixed> | [Array<string>, string]
|
|
1081
|
-
): (
|
|
1082
|
-
name: JestTestName,
|
|
1083
|
-
fn?: (...args: Array<any>) => ?Promise<mixed>,
|
|
1084
|
-
timeout?: number,
|
|
1085
|
-
) => void,
|
|
1086
|
-
},
|
|
1087
|
-
/**
|
|
1088
|
-
* Skip running this test
|
|
1089
|
-
*
|
|
1090
|
-
* @param {JestTestName} Name of Test
|
|
1091
|
-
* @param {Function} Test
|
|
1092
|
-
* @param {number} Timeout for the test, in milliseconds.
|
|
1093
|
-
*/
|
|
1094
|
-
skip: {
|
|
1095
|
-
(
|
|
1096
|
-
name: JestTestName,
|
|
1097
|
-
fn?: (done: JestDoneFn) => ?Promise<mixed>,
|
|
1098
|
-
timeout?: number,
|
|
1099
|
-
): void,
|
|
1100
|
-
each(
|
|
1101
|
-
...table: Array<Array<mixed> | mixed> | [Array<string>, string]
|
|
1102
|
-
): (
|
|
1103
|
-
name: JestTestName,
|
|
1104
|
-
fn?: (...args: Array<any>) => ?Promise<mixed>,
|
|
1105
|
-
timeout?: number,
|
|
1106
|
-
) => void,
|
|
1107
|
-
},
|
|
1108
|
-
/**
|
|
1109
|
-
* Highlight planned tests in the summary output
|
|
1110
|
-
*
|
|
1111
|
-
* @param {String} Name of Test to do
|
|
1112
|
-
*/
|
|
1113
|
-
todo(name: string): void,
|
|
1114
|
-
/**
|
|
1115
|
-
* Run the test concurrently
|
|
1116
|
-
*
|
|
1117
|
-
* @param {JestTestName} Name of Test
|
|
1118
|
-
* @param {Function} Test
|
|
1119
|
-
* @param {number} Timeout for the test, in milliseconds.
|
|
1120
|
-
*/
|
|
1121
|
-
concurrent(
|
|
1122
|
-
name: JestTestName,
|
|
1123
|
-
fn?: (done: JestDoneFn) => ?Promise<mixed>,
|
|
1124
|
-
timeout?: number,
|
|
1125
|
-
): void,
|
|
1126
|
-
/**
|
|
1127
|
-
* each runs this test against array of argument arrays per each run
|
|
1128
|
-
*
|
|
1129
|
-
* @param {table} table of Test
|
|
1130
|
-
*/
|
|
1131
|
-
each(
|
|
1132
|
-
...table: Array<Array<mixed> | mixed> | [Array<string>, string]
|
|
1133
|
-
): (
|
|
1134
|
-
name: JestTestName,
|
|
1135
|
-
fn?: (...args: Array<any>) => ?Promise<mixed>,
|
|
1136
|
-
timeout?: number,
|
|
1137
|
-
) => void,
|
|
1138
|
-
...
|
|
1139
|
-
};
|
|
1140
|
-
|
|
1141
|
-
declare function fit(
|
|
1142
|
-
name: JestTestName,
|
|
1143
|
-
fn: (done: JestDoneFn) => ?Promise<mixed>,
|
|
1144
|
-
timeout?: number,
|
|
1145
|
-
): void;
|
|
1146
|
-
/** An individual test unit */
|
|
1147
|
-
declare var test: typeof it;
|
|
1148
|
-
/** A disabled group of tests */
|
|
1149
|
-
declare var xdescribe: typeof describe;
|
|
1150
|
-
/** A focused group of tests */
|
|
1151
|
-
declare var fdescribe: typeof describe;
|
|
1152
|
-
/** A disabled individual test */
|
|
1153
|
-
declare var xit: typeof it;
|
|
1154
|
-
/** A disabled individual test */
|
|
1155
|
-
declare var xtest: typeof it;
|
|
1156
|
-
|
|
1157
|
-
type JestPrettyFormatColors = {
|
|
1158
|
-
comment: {
|
|
1159
|
-
close: string,
|
|
1160
|
-
open: string,
|
|
1161
|
-
...
|
|
1162
|
-
},
|
|
1163
|
-
content: {
|
|
1164
|
-
close: string,
|
|
1165
|
-
open: string,
|
|
1166
|
-
...
|
|
1167
|
-
},
|
|
1168
|
-
prop: {
|
|
1169
|
-
close: string,
|
|
1170
|
-
open: string,
|
|
1171
|
-
...
|
|
1172
|
-
},
|
|
1173
|
-
tag: {
|
|
1174
|
-
close: string,
|
|
1175
|
-
open: string,
|
|
1176
|
-
...
|
|
1177
|
-
},
|
|
1178
|
-
value: {
|
|
1179
|
-
close: string,
|
|
1180
|
-
open: string,
|
|
1181
|
-
...
|
|
1182
|
-
},
|
|
1183
|
-
...
|
|
1184
|
-
};
|
|
1185
|
-
|
|
1186
|
-
type JestPrettyFormatIndent = string => string;
|
|
1187
|
-
type JestPrettyFormatRefs = Array<any>;
|
|
1188
|
-
type JestPrettyFormatPrint = any => string;
|
|
1189
|
-
type JestPrettyFormatStringOrNull = string | null;
|
|
1190
|
-
|
|
1191
|
-
type JestPrettyFormatOptions = {
|
|
1192
|
-
callToJSON: boolean,
|
|
1193
|
-
edgeSpacing: string,
|
|
1194
|
-
escapeRegex: boolean,
|
|
1195
|
-
highlight: boolean,
|
|
1196
|
-
indent: number,
|
|
1197
|
-
maxDepth: number,
|
|
1198
|
-
min: boolean,
|
|
1199
|
-
plugins: JestPrettyFormatPlugins,
|
|
1200
|
-
printFunctionName: boolean,
|
|
1201
|
-
spacing: string,
|
|
1202
|
-
theme: {
|
|
1203
|
-
comment: string,
|
|
1204
|
-
content: string,
|
|
1205
|
-
prop: string,
|
|
1206
|
-
tag: string,
|
|
1207
|
-
value: string,
|
|
1208
|
-
},
|
|
1209
|
-
};
|
|
1210
|
-
|
|
1211
|
-
type JestPrettyFormatPlugin = {
|
|
1212
|
-
print: (
|
|
1213
|
-
val: any,
|
|
1214
|
-
serialize: JestPrettyFormatPrint,
|
|
1215
|
-
indent: JestPrettyFormatIndent,
|
|
1216
|
-
opts: JestPrettyFormatOptions,
|
|
1217
|
-
colors: JestPrettyFormatColors,
|
|
1218
|
-
) => string,
|
|
1219
|
-
test: any => boolean,
|
|
1220
|
-
...
|
|
1221
|
-
};
|
|
1222
|
-
|
|
1223
|
-
type JestPrettyFormatPlugins = Array<JestPrettyFormatPlugin>;
|
|
1224
|
-
|
|
1225
|
-
/** The expect function is used every time you want to test a value */
|
|
1226
|
-
declare var expect: {
|
|
1227
|
-
/** The object that you want to make assertions against */
|
|
1228
|
-
(
|
|
1229
|
-
value: any,
|
|
1230
|
-
): JestExpectType &
|
|
1231
|
-
JestPromiseType &
|
|
1232
|
-
EnzymeMatchersType &
|
|
1233
|
-
DomTestingLibraryType &
|
|
1234
|
-
JestJQueryMatchersType &
|
|
1235
|
-
JestStyledComponentsMatchersType &
|
|
1236
|
-
JestExtendedMatchersType &
|
|
1237
|
-
SnapshotDiffType,
|
|
1238
|
-
/** Add additional Jasmine matchers to Jest's roster */
|
|
1239
|
-
extend(matchers: {[name: string]: JestMatcher, ...}): void,
|
|
1240
|
-
/** Add a module that formats application-specific data structures. */
|
|
1241
|
-
addSnapshotSerializer(pluginModule: JestPrettyFormatPlugin): void,
|
|
1242
|
-
assertions(expectedAssertions: number): void,
|
|
1243
|
-
hasAssertions(): void,
|
|
1244
|
-
any(value: mixed): JestAsymmetricEqualityType,
|
|
1245
|
-
anything(): any,
|
|
1246
|
-
// MODIFIED: Array -> $ReadOnlyArray
|
|
1247
|
-
arrayContaining(value: $ReadOnlyArray<mixed>): Array<mixed>,
|
|
1248
|
-
objectContaining(value: Object): Object,
|
|
1249
|
-
/** Matches any received string that contains the exact expected string. */
|
|
1250
|
-
stringContaining(value: string): string,
|
|
1251
|
-
stringMatching(value: string | RegExp): string,
|
|
1252
|
-
not: {
|
|
1253
|
-
arrayContaining: (value: $ReadOnlyArray<mixed>) => Array<mixed>,
|
|
1254
|
-
objectContaining: (value: {...}) => Object,
|
|
1255
|
-
stringContaining: (value: string) => string,
|
|
1256
|
-
stringMatching: (value: string | RegExp) => string,
|
|
1257
|
-
...
|
|
1258
|
-
},
|
|
1259
|
-
...
|
|
1260
|
-
};
|
|
1261
|
-
|
|
1262
|
-
// TODO handle return type
|
|
1263
|
-
// http://jasmine.github.io/2.4/introduction.html#section-Spies
|
|
1264
|
-
declare function spyOn(value: mixed, method: string): Object;
|
|
1265
|
-
|
|
1266
|
-
/** Holds all functions related to manipulating test runner */
|
|
1267
|
-
declare var jest: JestObjectType;
|
|
1268
|
-
|
|
1269
|
-
/**
|
|
1270
|
-
* The global Jasmine object, this is generally not exposed as the public API,
|
|
1271
|
-
* using features inside here could break in later versions of Jest.
|
|
1272
|
-
*/
|
|
1273
|
-
declare var jasmine: {
|
|
1274
|
-
DEFAULT_TIMEOUT_INTERVAL: number,
|
|
1275
|
-
any(value: mixed): JestAsymmetricEqualityType,
|
|
1276
|
-
anything(): any,
|
|
1277
|
-
arrayContaining(value: Array<mixed>): Array<mixed>,
|
|
1278
|
-
clock(): JestClockType,
|
|
1279
|
-
createSpy(name: string): JestSpyType,
|
|
1280
|
-
createSpyObj(
|
|
1281
|
-
baseName: string,
|
|
1282
|
-
methodNames: Array<string>,
|
|
1283
|
-
): {[methodName: string]: JestSpyType, ...},
|
|
1284
|
-
objectContaining(value: Object): Object,
|
|
1285
|
-
stringMatching(value: string): string,
|
|
1286
|
-
...
|
|
1287
|
-
};
|