From the course: Building Modern Projects with React
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Testing reducers - React.js Tutorial
From the course: Building Modern Projects with React
Testing reducers
- Alright, so the first type of thing that we're going to talk about testing here is reducers. And specifically, if we open up the slices that we created. Such as the to-do slice. The main thing that we want to be able to test here is the functionality of each of these things here. So the same thing would be true for the other slice as well, that we created. The loading slice. Basically, we just want to have a way to test that each of these things is going to modify the state in the way that we want it to. Alright, now at first glance, this might seem a little bit more complicated than it really is. It's actually very simple. So if we wanted to test, for example, one of these, let's say one of these loading slices. All right? For example, the loading started slice. All we really need to do here is check to make sure that when this function here is called, it operates on the state in the way that we want it to. So let's just create a simple function here. We'll create a file of course,…