---
title: "Discussion on \"A better approach for testing your Redux code\" | Hashnode"
description: "Discussion on \"A better approach for testing your Redux code\". The right level of granularity is key"
url: "https://hashnode.com/posts/a-better-approach-for-testing-your-redux-code/5ddb17a11d03daa468a991fc"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [A better approach for testing your Redux code](https://blog.hbarcelos.dev/a-better-approach-for-testing-your-redux-code?utm_source=hashnode&utm_medium=feed)

The right level of granularity is key

Nov 25, 2019 · 20 min read · blog.hbarcelos.dev  
Updated Jan 10, 2023  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#redux](https://hashnode.com/tag/redux)
-   [#testing](https://hashnode.com/tag/testing)
-   [#tdd](https://hashnode.com/tag/tdd)

## Written by

[Henrique Barcelos](https://hashnode.com/@hbarcelos)

@hbarcelos · Planet Earth, Milky Way

  
[View profile](https://hashnode.com/@hbarcelos)

Software Engineer | Software Architect | Blockchain Enthusiast

## Responses 2

Markdown supported · ⌘↵ to post

[Slim](https://hashnode.com/@slimhs)

[Apr 2, 2020](https://hashnode.com/posts/a-better-approach-for-testing-your-redux-code/5ddb17a11d03daa468a991fc/comment/5e85d92907bee7152c3e2900)

[Henrique Barcelos](https://hashnode.com/@hbarcelos) Very interesting and amazing article, you can update it using `createAsyncThunk` in v1.3.2 for async actions. But I have a simple question here: why are you adding the error as selector in the code and is it useful to do that?

[Henrique Barcelos](https://hashnode.com/@hbarcelos)

[Apr 22, 2020](https://hashnode.com/posts/a-better-approach-for-testing-your-redux-code/5ddb17a11d03daa468a991fc/comment/5e85d92907bee7152c3e2900#reply-5ea02ed612892a3c760b379f)

I have heard of `createAsyncThunk`, but didn't have a chance to play with it yet. As soon as I got some spare time I'll do that. Thanks.

I use selectors for anything I might want to use in a component.

Sometimes I want to provide feedback to the user about an action that failed, even if I need to embellish it first. For that reason, I need to extract the error from the store, therefore the selector.

[Syed Fazle Rahman](https://hashnode.com/@fazlerocks)

[Nov 25, 2019](https://hashnode.com/posts/a-better-approach-for-testing-your-redux-code/5ddb17a11d03daa468a991fc/comment/5ddbbfc3f0d5045842d5fcfa)

Nice read, thanks for sharing [Henrique Barcelos](https://hashnode.com/@hbarcelos). :)
