jeudi 23 mai 2019

Error on testing redux with sagas with jest

I a sagas.factory and want to test it, but i'm havingn some problems...

I've created the sagas like

export const tasksFetchRequestSagaFactory = ({service}) => {
  return function* () {
    const request = yield put(service())
    console.log(request)
    yield put(tasksFetchSuccess(request))
  }
}

and I have the test

const gen = tasksFetchRequestSagaFactory(tasksFetchService({service: tasksFetchService}))
  it('should be called correctly', () => {
        expect(gen.next().value).toEqual(put(tasksFetchService()))
      })

But when trying to run the test i'm getting some errors

  TypeError: Cannot destructure property `service` of 'undefined' or 'null'.

      2 | import { tasksFetchSuccess } from './tasks.actions'
      3 | 
    > 4 | export const tasksFetchRequestSagaFactory = ({service}) => {
        |                                             ^
      5 |   return function* () {
      6 |     const request = yield put(service())
      7 |     console.log(request)


Aucun commentaire:

Enregistrer un commentaire