I
I
ilyaux2020-06-12 13:08:00
Unit testing
ilyaux, 2020-06-12 13:08:00

How to test redux via jest?

How to check redux action is working?
and as a result of the execution, check the dataState for the presence of data?

For example:

Test the authorization function in the application.
expect(AuthMethod(login, password));

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-06-12
@dimoff66

const store = Redux.createStore(yourReducer)
store.dispatch(AuthMethod(login, password))
const value = store.getState().someKey // вместо someKey нужный вам ключ

And then you compare value with the expected value

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question