text: Q:
  
  React Native - How do I specify state in tests?
  
  I am currently working on a React Native component that uses local state to control some UI elements, ie, some elements are only rendered if some values in state are set to true. These values change depending on clicks within the component.
  Is there a way for me to specify initial state when testing using react's TestRenderer? If not, how could I go around to testing this? I'd like to be able to render the component for certain states and test over it. Any helpful input is very much appreciated.
  I can provide more detail if necessary.
  Thanks in advance.
  EDIT: Adding an example illustrating my code. This is not my component code but it illustrates its behavior:
  interface IMyComponentProps {
      ...
  }
  
  interface IMyComponentState {
      showForm: boolean;
  }
  
  export class MyComponent extends React.Component<IMyComponentProps, IMyComponentState> {
      constructor(props: any) {
          super(props);
          // showForm is initially false
          this.state = {
              showForm: false,
          };
      }
  
      public render() {
          // if showForm is true then render my form component
          if (this.state.showForm) {
              return <FormComponent />;
          } else {
              // otherwise render button that changes the state to showForm: true
              // and causes a re-render
              return <Button onClick={this.buttonClickFn} />;
          }
      }
  
      private buttonClickFn = () => this.setState({...this.state, showForm: true});
  }
  
  A:
  
  The state can be directly set for testing purposes:
  componentInstance.state.showForm = true;
  componentInstance.forceUpdate();
  
  