A
A
AlexKindGeek2018-09-08 21:00:56
React
AlexKindGeek, 2018-09-08 21:00:56

Testing React Redux?

Hello everyone :)
I'm about to start a new project (React + Redux) and would like to cover it with tests (TDD). I read and understood that Jest + Enzyme is best suited for this.
I have a few questions:
1. Is it worth testing each component, action and reducer, or is the test written to the component (which has actions, mapState, etc.) ??
2. Are there any tutorials about testing (I searched, found a few, but they are too superficial)?
3. What do you use for tests?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2018-09-09
@AlexKindGeek

1 - yes, it is worth testing each action, reducer (unit tests) and some moments from the components (since you can take a snapshot for the entire component + point-wise cover the desired places with unit tests). All functions that you have in utils / helpers (auxiliary) also need to be covered by unit tests.
2 - Tutorials for unit testing:
a) testing logic (actions/reducers)
b) testing components (including snapshots)
3) Jest, enzyme. I tried (and also not bad) - mocha, chai. For e2e we used puppetter, cypress looks interesting. For testing sagas with unit tests - either on the doc or with redux-saga-test-plan

A
Anton Filippov, 2018-09-08
@vicodin

hack redux-saga too, sagas are easier to test

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question