mirror of
https://github.com/callstack/react-native-testing-library.git
synced 2026-09-18 23:09:04 +08:00
fix: remove deprecated existential Flow type and use any for now (#77)
<!-- Please provide enough information so that others can review your pull request. --> <!-- Keep pull requests small and focused on a single change. --> ### Summary Existential type (`*`) is long deprecated, let's just use `any` for now. ### Test plan Added some more Flow typings to `shallow.test.js` that were failing because of existential type.
This commit is contained in:
committed by
GitHub
parent
6dfbc6794b
commit
c5910d94e4
@@ -13,7 +13,9 @@ exports[`shallow rendering React Test Instance 1`] = `
|
||||
`;
|
||||
|
||||
exports[`shallow rendering React elements 1`] = `
|
||||
<View>
|
||||
<View
|
||||
testID="2"
|
||||
>
|
||||
<Text
|
||||
testID="text-button"
|
||||
>
|
||||
|
||||
@@ -3,14 +3,18 @@ import React from 'react';
|
||||
import { View, Text } from 'react-native';
|
||||
import { shallow, render } from '..';
|
||||
|
||||
const TextPress = () => (
|
||||
<View>
|
||||
type Props = {|
|
||||
+dummyID?: string,
|
||||
|};
|
||||
|
||||
const TextPress = ({ dummyID }: Props) => (
|
||||
<View testID={dummyID}>
|
||||
<Text testID="text-button">Press me</Text>
|
||||
</View>
|
||||
);
|
||||
|
||||
test('shallow rendering React elements', () => {
|
||||
const { output } = shallow(<TextPress />);
|
||||
const { output } = shallow(<TextPress dummyID="2" />);
|
||||
|
||||
expect(output).toMatchSnapshot();
|
||||
});
|
||||
|
||||
+6
-3
@@ -10,11 +10,11 @@ import format from './helpers/format';
|
||||
* Log pretty-printed deep test component instance
|
||||
*/
|
||||
function debugDeepElementOrInstance(
|
||||
instance: React.Element<*> | ?ReactTestRendererJSON,
|
||||
instance: React.Element<any> | ?ReactTestRendererJSON,
|
||||
message?: any = ''
|
||||
) {
|
||||
try {
|
||||
// We're assuming React.Element<*> here and fallback to
|
||||
// We're assuming React.Element<any> here and fallback to
|
||||
// rendering ?ReactTestRendererJSON
|
||||
// $FlowFixMe
|
||||
const { toJSON } = render(instance);
|
||||
@@ -29,7 +29,10 @@ function debugDeepElementOrInstance(
|
||||
}
|
||||
}
|
||||
|
||||
function debug(instance: ReactTestInstance | React.Element<*>, message?: any) {
|
||||
function debug(
|
||||
instance: ReactTestInstance | React.Element<any>,
|
||||
message?: any
|
||||
) {
|
||||
return debugShallow(instance, message);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import format from './format';
|
||||
* Log pretty-printed shallow test component instance
|
||||
*/
|
||||
export default function debugShallow(
|
||||
instance: ReactTestInstance | React.Element<*>,
|
||||
instance: ReactTestInstance | React.Element<any>,
|
||||
message?: any
|
||||
) {
|
||||
const { output } = shallow(instance);
|
||||
|
||||
+2
-2
@@ -11,8 +11,8 @@ import debugDeep from './helpers/debugDeep';
|
||||
* to assert on the output.
|
||||
*/
|
||||
export default function render(
|
||||
component: React.Element<*>,
|
||||
options?: { createNodeMock: (element: React.Element<*>) => any }
|
||||
component: React.Element<any>,
|
||||
options?: { createNodeMock: (element: React.Element<any>) => any }
|
||||
) {
|
||||
const renderer = TestRenderer.create(component, options);
|
||||
const instance = renderer.root;
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import ShallowRenderer from 'react-test-renderer/shallow'; // eslint-disable-lin
|
||||
* Renders test component shallowly using react-test-renderer/shallow
|
||||
*/
|
||||
export default function shallow(
|
||||
instance: ReactTestInstance | React.Element<*>
|
||||
instance: ReactTestInstance | React.Element<any>
|
||||
) {
|
||||
const renderer = new ShallowRenderer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user