1

如何检查该TextInput组件是否聚焦?我知道如何在网上做到这一点:

const input = getByPlaceholderText("placeholder");
expect(document.activeElement).toEqual(input);

但是如何在 React Native 中做同样的事情呢?

  it('should have focus', () => {
    const { getByTestId } = render(<TextInput autoFocus testID={ 'alpha' }/>);
    const textInput = getByTestId('alpha');

    // and then ..?
  });
4

0 回答 0