Skip to content

Tape support #28

@adamyonk

Description

@adamyonk

I can get the tests working with something like this:

test('someThunk', (t) => {
  registerMiddlewares([thunk])
  registerInitialStoreState(buildInitialStoreState(rootReducer))

  const expectedActions = [
    actions...
  ]

  const initialState = {
    ...
  }

  assertions.toDispatchActionsWithState(
    initialState,
    someAction(),
    expectedActions,
    t.end
  )
})

This kind of works, because if something goes wrong in toDispatchActionsWithState, tape catches the thrown error and fails the test run, but it doesn't count the test in the tape output when it's passing, because you never actually assert anything with tape (t.equal, t.deepEqual, etc.). If there was some way to get the output actions of toDispatchActionsWithState, I could do some assertion like this:

  const expectedActions = [
    actions...
  ]

  const initialState = {
    ...
  }

  assertions.toDispatchActionsWithState(
    initialState,
    someAction(),
    expectedActions,
    (actualActions) => {
      t.deepEqual(
         actualActions,
         expectedActions,
         'should run the correct actions'
      )
    }
  )

I saw that you can pass a done and fail function in, but I think that would leave us in the same boat here. I'm not sure that an actual tape integration is necessary, if there is a way to get at the array of the actions that were dispatched and to not have a mismatch throw an error (so it could be handled by equal, deepEqual, and friends.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions