Skip to content

Is it possible to test the contents of a TextInput? #905

Closed Answered by mdjastrzebski
charlestbell asked this question in Q&A

You must be logged in to vote

Not sure if I understand your question correctly, but let's try. Your goal is to check whether the TextInput value is as you expected after some test initialization.

I'm getting this test to pass correctly:

test('repro', async () => {
  const onChangeTest = jest.fn();
  const onInputChange = jest.fn();

  const view = render(
    <TextInput
      allowFontScaling={true}
      editable={true}
      id="name"
      initialValue="Youspan"
      label="Name"
      maxLength={48}
      onChangeText={onChangeTest}
      onInputChange={onInputChange}
      placeholder="Name"
      rejectResponderTermination={true}
      style={{ marginLeft: 2 }}
      testID="entryScreen.trainingGoal"
      unde…

Replies: 2 comments 2 replies

You must be logged in to vote
1 reply
@charlestbell

Answer selected by charlestbell

You must be logged in to vote
1 reply
@mdjastrzebski

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants