D
D
DisaPadla2015-12-19 19:28:44
React
DisaPadla, 2015-12-19 19:28:44

How to test React?

Started with tests to understand in react. We have a component and functions are passed to it through props. A few questions. All the data that gets into the component needs to be emulated in the test, right? And what if I need to test, for example, a checkbox only in a component, how can I do this? We write in the TestUtils.renderIntoDocument(); How to get the desired checkbox or other element next?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
endenwer, 2015-12-24
@endenwer

There are several approaches to testing React. You either render the component to the DOM and then you can use jQuery to work with that DOM, for example. You can use Shallow Rendering (the authors recommend this method). In this case, there is no DOM. I would advise you to use Enzyme for tests . These helpers greatly simplify the tests.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question