redux-things/redux-actions-assertions

Problems with Jest matchers

adamyonk opened this issue · 2 comments

@giuband thanks for adding the jest matchers!

I was just trying them out and it looks to me like jest matchers are always passing no matter what. This test:

  it('should run the correct actions', () => {
    expect(deleteTagSet(tagSet))
      .toDispatchActionsWithState(
        { currentTagSet: { ...tagSet }, tagSets: [], options: { queryStringControl: false } },
        expected,
        done => console.log(done)
      )
  })

results in

messages image 2856963559

but changing the expected actions array to something bogus like

  it('should run the correct actions', () => {
    expect(deleteTagSet(tagSet))
      .toDispatchActionsWithState(
        { currentTagSet: { ...tagSet }, tagSets: [], options: { queryStringControl: false } },
        expected.concat({ type: 'bogus'}),
        done => console.log(done)
      )
  })

results in

screen shot 2017-01-19 at 8 25 35 am

It seems like the assertions are being run and passing/failing correctly, but the promise isn't being handed back correctly to jest, and it's marking every test as passing.

Hi @adamyonk, at first sight I'd say you are missing the done callback parameter.
Could you please try changing:

it('should run the correct actions', () => {

into:

it('should run the correct actions', (done) => {

and replace done => console.log(done) with simply done in the parameters of toDispatchActionsWithState.

Let me know if this helps.

@giuband gah, that was it, thanks!