Skip to content

Testing Store

thaoln87 edited this page Jul 7, 2017 · 1 revision

Purpose

  • Integration test
  • Test Store's state

Steps

Create store with reducers and initial state

const store = createStore(rootReducer, initialState);

Create actions

 const course = {title: 'Clean code'};
 const action = courseActions.createCourseSuccess(course);

Dispatch actions

store.dispatch(action);

Assert output state

  • getState(): get state from Store
    const actual = store.getState().courses[0];
    expect(actual).toEqual(course);
Clone this wiki locally