apollographql / react-apollo

:recycle: React integration for Apollo Client
https://www.apollographql.com/docs/react/
MIT License
6.85k stars 790 forks source link

MockedProvider mocking `null` data #4025

Closed coltonehrman closed 4 years ago

coltonehrman commented 4 years ago

I am trying to mock returning null in a query, but MockedProvider is not allowing me to do it.

Below, you can see the mock that I am trying to use

Screen Shot 2020-06-18 at 12 57 10 AM

Below is the component that is being tested

Screen Shot 2020-06-18 at 12 57 56 AM

Below is the gql query that is being mocked

Screen Shot 2020-06-18 at 12 58 21 AM

Below are the typedef definitions

Screen Shot 2020-06-18 at 12 58 40 AM

I want to run a test when session is completely null, is this possible with MockedProvider and the way I have everything setup?

coltonehrman commented 4 years ago

Related I was missing the data prop in mocks

    const mocks = [
      {
        request: { query: GET_APP },
        result: {
          data: {
            lessons: [],
            session: null,
            alerts: []
          }
        }
      }
    ]