Answer the question
In order to leave comments, you need to log in
How to get a button from a child component in tests?
A simple test for the presence of a button by its text.
test('render search button', async () => {
const { getByText } = render(<Home />);
const searchButton = getByText('Search');
expect(searchButton).toBeInTheDocument();
});
<form onSubmit={this.submitSearching.bind(this)} className="search-input">
<Search />
</form>
<button onClick={this.buttonClick.bind(this)} type="submit" className="input-btn">
Search
</button>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question