Hey I am trying to implement the react-native-testing-library for a project which is also using TypeScript. My question involves the best way to pass props to my tests.
For example if my src/example.tsx is:
import React from 'react';import { Button, View } from 'react-native';export interface Props { text: string; func: () => void;}export const Example: React.FC<Props> = ({ text, func }: Props) => { return (<View><Button onPress={func} title={text} /></View> )}
And my src/test/example.test.tsx is:
import React from 'react';import { render } from '@testing-library/react-native';import { Example, Props } from '../example';describe('example', () => { const { getAllBy } = render(<Example {...Props} />); <---- *Error}
I obviously get the error:
'Props' only refers to a type, but is being used as a value here.
What is the best way to do this. Do I need to manually create a mock props object to feed into each of my components or is there a better way to do this?