Error testing in Registry/React Authentication

Asked

Viewed 39 times

0

I am working on an application, in which the tests are already defined. After the implementation I am having some errors such as:

src/tests/Homepage.test.js
Test Homepage Component uses Router for logout Functionality

Invariant Violation: Could not find "store" in either the context or props of "Connect(HomePage)". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(HomePage)".

src/App.test.js
Test Appcomponent check route, Dispatch and store setup for Component

Given action "USERS_LOGOUT", reducer "authentication" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hol

d no value, you can Return null Instead of Undefined.

Test Appcomponent check for redirections

Given action "USERS_LOGOUT", reducer "authentication" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hol

d no value, you can Return null Instead of Undefined.

Test Appcomponent
check route, Dispatch and store setup for Component (57ms)
check for redirections (4ms)

Can someone give me a suggestion?

Source code: github.com/dropecosta/React-Redux-Authentication

Thank you!

1 answer

0

This test src/tests/Homepage.test.js is failing because you are testing a connect component with Redux but not passing the Store, I believe that if you do something like this the test will pass.

<Provider store={mockStore}>
    <HomePage />
</Provider>

Now the other two tests I believe is giving problem for lack of data in the store, but I can not be sure of this.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.