From the course: Building Modern Projects with React

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Testing Redux thunks

Testing Redux thunks

From the course: Building Modern Projects with React

Start my 1-month free trial

Testing Redux thunks

- [Instructor] Now let's move onto testing thunks. Admittedly, thunks can sometimes be one of the trickier things to test, but I think I've figured out a decent way to do so. Keep in mind that this is probably just one way to test thunks and depending on your situation there might be better ways to do it. So with that disclaimer, let's start off by creating a new file in our tests folder called thunks.test.js and then just like with our reducer tests we're going to say import expect from chai and we're going to import our loadTodos thunk which is what we'll be using for the example from ../thunks. And once we've done that we're going to create a describe block, describe, and as I mentioned, in this video, we're going to be writing a basic test for the loadTodos thunk. So we'll say describe the loadTodos thunk. And now that we have that we have to actually think about what it is we want to test about our loadTodos…

Contents