danielstern / isomorphic-react

A simple but powerful React application built on a standards-compliant back-end
https://isomorphic-react-x.herokuapp.com/
380 stars 259 forks source link

TypeError: (0 , _fetchQuestionSaga.handleFetchQuestion) is not a function #52

Closed pablotdv closed 3 years ago

pablotdv commented 3 years ago

On module 6 in the "Mocking - Demo" video, a get the error "TypeError: (0 , _fetchQuestionSaga.handleFetchQuestion) is not a function"

This is that I have

import { handleFetchQuestion } from "./fetch-question-saga";

describe("Fetch questions saga", () => {
  it("should fetch the questions", async () => {
    const gen = handleFetchQuestion({ question_id: 42 });
    const { value } = await gen.next();
  });
});

The jest output is

 FAIL  src/sagas/fetch-question-saga.spec.js
  Fetch questions saga
    × should fetch the questions (2 ms)

  ● Fetch questions saga › should fetch the questions

    TypeError: (0 , _fetchQuestionSaga.handleFetchQuestion) is not a function

      3 | describe("Fetch questions saga", () => {
      4 |   it("should fetch the questions", async () => {
    > 5 |     const gen = handleFetchQuestion({ question_id: 42 });
        |                 ^
      6 |     const { value } = await gen.next();
      7 |   });
      8 | });

      at Object.<anonymous> (src/sagas/fetch-question-saga.spec.js:5:17)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        2.148 s
Ran all test suites matching /fetch-question/i.
pablotdv commented 3 years ago

I found my error.

On master branch, the fetch-question-saga.js does not export the handleFetchQuestion function