redux-things / redux-actions-assertions

Simplify testing of redux action and async action creators
http://redux-things.github.io/redux-actions-assertions/
MIT License
188 stars 11 forks source link

Problems with Jest matchers #37

Closed adamyonk closed 7 years ago

adamyonk commented 7 years ago

@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.

giuband commented 7 years ago

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.

adamyonk commented 7 years ago

@giuband gah, that was it, thanks!