diff --git a/docs/api.md b/docs/api.md index 1aa3eecc3..75123f5ab 100644 --- a/docs/api.md +++ b/docs/api.md @@ -8,10 +8,10 @@ Defined as: ```jsx function render( - component: React.Element<*>, + component: React.Element, options?: { /* You won't often use this, but it's helpful when testing refs */ - createNodeMock: (element: React.Element<*>) => any, + createNodeMock: (element: React.Element) => any, } ): RenderResult {} ``` @@ -77,7 +77,7 @@ A method returning an array of `ReactTestInstance`s with matching a React compon > This method has been **deprecated** because using it results in fragile tests that may break between minor React Native versions. It will be removed in next major release (v2.0). Use [`getAllByType`](#getallbytype-type-reactcomponenttype) instead. -### `update: (element: React.Element<*>) => void` +### `update: (element: React.Element) => void` Re-render the in-memory tree with a new root element. This simulates a React update at the root. If the new element has the same type and key as the previous element, the tree will be updated; otherwise, it will re-mount a new tree. diff --git a/src/__tests__/__snapshots__/shallow.test.js.snap b/src/__tests__/__snapshots__/shallow.test.js.snap index ec845ddca..37c0b834a 100644 --- a/src/__tests__/__snapshots__/shallow.test.js.snap +++ b/src/__tests__/__snapshots__/shallow.test.js.snap @@ -13,7 +13,9 @@ exports[`shallow rendering React Test Instance 1`] = ` `; exports[`shallow rendering React elements 1`] = ` - + diff --git a/src/__tests__/shallow.test.js b/src/__tests__/shallow.test.js index a806518fc..927ee1bfc 100644 --- a/src/__tests__/shallow.test.js +++ b/src/__tests__/shallow.test.js @@ -3,14 +3,18 @@ import React from 'react'; import { View, Text } from 'react-native'; import { shallow, render } from '..'; -const TextPress = () => ( - +type Props = {| + +dummyID?: string, +|}; + +const TextPress = ({ dummyID }: Props) => ( + Press me ); test('shallow rendering React elements', () => { - const { output } = shallow(); + const { output } = shallow(); expect(output).toMatchSnapshot(); }); diff --git a/src/debug.js b/src/debug.js index 0cd63a100..807eaa571 100644 --- a/src/debug.js +++ b/src/debug.js @@ -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 | ?ReactTestRendererJSON, message?: any = '' ) { try { - // We're assuming React.Element<*> here and fallback to + // We're assuming React.Element 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, + message?: any +) { return debugShallow(instance, message); } diff --git a/src/helpers/debugShallow.js b/src/helpers/debugShallow.js index 1df224360..896e059d3 100644 --- a/src/helpers/debugShallow.js +++ b/src/helpers/debugShallow.js @@ -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, message?: any ) { const { output } = shallow(instance); diff --git a/src/render.js b/src/render.js index a953e90e0..3262645ee 100644 --- a/src/render.js +++ b/src/render.js @@ -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, + options?: { createNodeMock: (element: React.Element) => any } ) { const renderer = TestRenderer.create(component, options); const instance = renderer.root; diff --git a/src/shallow.js b/src/shallow.js index 65509330c..e07b123ca 100644 --- a/src/shallow.js +++ b/src/shallow.js @@ -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 ) { const renderer = new ShallowRenderer();