I'm writing a React Native components using TypeScript and testing them with React Native Testing Library.
I want to put a testId attribute on a React Native component like so:
<TextInput testId="foo" />
And then refer to it in a test like so:
it('receives a search string', () => { const { getByTestId } = render(<FooComponent />);; const textBox = getByTestId("foo"); fireEvent.changeText(textBox,"some fake text"); expect(textBox.value).toEqual("some fake text");});
But TypeScript won't allow me to put a testId
attribute on a component.
How do I get TypeScript to recognize the added attributes like testId
from @testing-library/react-native.