Skip to content

Insufficient Documentation: Testing - Building a new store for each test. #4239

@charlestbell

Description

@charlestbell

What docs page needs to be fixed?

I'd like to request an addition to the docs.
Here on this page: https://redux.js.org/usage/writing-tests#connected-components
The writer gives a very simple example of testing redux. What they don't discuss, is how set up your redux state for each test.

Example:
I have 2 tests, one where the state is set up one way, another where needs to be set up differently. In the example given, this isn't possible, the state persists between tests, giving inconsistent tests results.

There are a few options out there, like redux-mock-store, which builds a completely new store for each test, but I don't see any mention of it officially. Or any replacement for that matter.

It seems like an oversight that an official method for providing a way to clean or redefine the redux store between each test is not provided.

Could someone please add that to the docs?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions