Skip to content

Test passes even if not all expected actions are dispatched #12

Closed
@dara76

Description

@dara76

I have the following set-up
actions.js

export function loadData() {
    return function (dispatch) {
        dispatch(transactions([876]));
    };
}

actions-test.js

  jest.dontMock('../actions');
  jest.dontMock('redux-mock-store');
  jest.dontMock('redux-thunk');

  const configureMockStore = require('redux-mock-store');
  const thunk = require('redux-thunk');
  const middlewares = [ thunk ];
  const mockStore = configureMockStore(middlewares);

describe('actions', () => {    
  it('should load data', (done) => {
    const expectedActions = [
      { type: actions.TRANSACTIONS, transactions : [876] },
      //{ type: actions.DOES_NOT_EXIST, foo : [] },
      //{ type: actions.EXISTS, foo : [] }
    ];

    const store = mockStore({}, expectedActions, done);
    store.dispatch(actions.loadData());
  });
});

Running the above test passes as expected.

The problem is if I uncomment

      //{ type: actions.DOES_NOT_EXIST, foo : [] },
      //{ type: actions.EXISTS, foo : [] }

the test still passes even though now only one of the 3 expectedActions is dispatched.

Is this a bug, or am I misunderstanding something?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions